What are portals in React?

Posted by Prem Tiwari | Updated on

What are portals in React?

Portal is a recommended way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.

The first argument is any render-able React child, such as an element, string, or fragment. The second argument is a DOM element.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers