The createPortal
API in React allows you to render child elements into a different part of the DOM, outside the current component's DOM hierarchy. This is particularly useful when you need to render content in a different DOM node, such as rendering a modal dialog or rendering React components into non-React server markup.
Iļ»æn the following example we see how we can use the createPortal API to render a Modal outside the current DOM hierarchy.