DEV Community

Discussion on: Building a modal in React.

Collapse
bthntprlk profile image
batu

Hi, nice article.

We prefer to use Modal components wrapped in a component which use ReactDOM.portal (comes with 16v) for better UI mechanism. Modals and popups are looks familiar but functionality. For example; you have a form in popup, and you have to show a modal if it’s successfully posted or failed badly. Modals needs to be above popup. We’ve created 2 roots like app-root; popup-root and modal-root in a large-scaled application. By this way render methods stay clean and UI flows properly without trading CSS hacks, thanks to DOM order.

Thank you for this article (:

Collapse
achowba profile image
Atauba Prince Author

Thanks for the comment, this is the first time I am hearing about ReactDOM.portal, I will go and check it out πŸ™‚.

Collapse
bthntprlk profile image
batu

(Y) basically it allows you to use components outside of your app-root.

See you (: