React TutorialLesson 36Free preview
React Portals
This lesson is part of React · All levels
Summary
React Portal allows components to render their children to DOM elements outside their parent hierarchy, such as capital attached to a document body. This feature is useful for elements that need to appear on top of other content such as dialog, tooltip, and dropdown. Although the DOM location is different, the event continues to flow normally following the component tree.
Key points
- CreatePortal comes from the react-dom package
- The first argument is children, the second is the DOM element of the goal.
- Suitable for capital, tooltip, popup, and toast
- Event React stays with the component tree, not the DOM position.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.