React Help
David Miller

David Miller @dmiller72

Location:
Kyle, Texas
Joined:
Sep 15, 2020

React Help

Publish Date: Sep 14 '23
0 1

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?

Comments 1 total

  • Lucas
    LucasSep 14, 2023

    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

Add comment