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

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay