DEV Community

David Miller
David Miller

Posted on

React Help

Here's a link codesandbox project I'm working on. Can anyone tell me why the button at the bottom of form component stops resetting the Rate component once I put it inside the ternerary operator, please?

Top comments (1)

Collapse
 
lucasm4sco profile image
Lucas • Edited

Hello David, I hope you are well!

Taking a look at your code, it seems to me that the default behavior of the button reset is not occurring, I believe it is due to its rendering conditionally, because as soon as the state variable changes in the Reset function, the component is disassembled and therefore the button loses its function in DOM.

If you still want to do conditional rendering in your code, take a look at using state variables for the select component or if you prefer, you can use a reference to the form to execute the reset event, I found a post with an example of how to use the select in React: Creating forms in React