'What is the performance difference between multiple ReactDOM.render and one ReactDOM.createPortal?

This is one of the questions I was asked during the interview, but I didn't answer it. What do you think?



Solution 1:[1]

Events are not propagated to the parent in render while it does in createPortal.

From the docs on React Portals,

This includes event bubbling. An event fired from inside a portal will propagate to ancestors in the containing React tree, even if those elements are not ancestors in the DOM tree.

Read this Event Bubbling Through Portals

Check this Demo,

Edit create-portal-vs-render

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1