DEV Community

Discussion on: React: Using portals to make a modal popup

Collapse
 
link2twenty profile image
Andrew Bone

You can use this code and pass in a form as the child.

Collapse
 
n1rjal profile image
Nirjal Paudel

The method is techically correct but not "REACT esk". If I would use, say email and password field, in the form and make it a controlled component by putting value and setValue. Each time the state changes due to onChange, the code freezes for split second and UX will be poor

Thread Thread
 
link2twenty profile image
Andrew Bone

That's React's official documentation. A redraw, due to state change, should not cause anything to freeze.

Thread Thread
 
link2twenty profile image
Andrew Bone

Here's an example