-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

React Interview Guide
By :

Nowadays, it is quite common to use model windows or popups on web pages to quickly grab the user’s attention. They help notify the user of some important information or ask the user to enter their input. But the implementation of these widgets is challenging in large apps since it involves writing complex CSS code and handling the DOM hierarchy. Fortunately, React provides the portals feature to solve these kinds of use cases.
Portals were introduced in 2017 and were first seen in React version 16. They are used to render React components outside of the DOM hierarchy. The usage of portals is not typical, but they are helpful in specific use cases, as you will see in the following subsections.
React portals allow you to render children into a DOM node that exists outside of the parent DOM hierarchy. Even though you render a child component outside the parent, the parent-child relationship still exists between...