DEV Community

loading...

Discussion on: Putting props to useState

Collapse
nibble profile image
Joseph Mawa • Edited

Which solution do you prefer?

Definitely not the modal one. Is the benefit of going the modal route worth changing my UI?

When you click on John, the DetailView component will be re-rendered (because it already exists on the screen), which means that John's email will not be put into our state

It would appear like DetailView is re-rendered because it already exists on the screen. That might through off total noobs. I would have preferred something like:

When you click on John, the DetailView component will be re-rendered without updating John's email in state. This is because after mount, it is expected you update email using dispatcher/setter setEmail.

Thanks for the article. It is quite informative.

Collapse
tkdodo profile image
Dominik D Author

Is the benefit of going the modal route worth changing my UI?

No, this was more of an example of how we already solve the issue with conditional rendering, which we also incidentally do a lot with modals :)