Chapter 13 · 9 examples
React portals and why do we need them
CSS: absolute positioning · Absolute is not that absolute · Understanding Stacking Context · Position: fixed. Escape the overflow · Stacking Context in real apps · How React Portal can solve this · React lifecycle, re-renders, Context, and Portals · CSS, native JavaScript, form submit, and Portals
- Example 1Absolute positioning a dialog
- Example 2Absolute is actually relative
- Example 3z-index and stacking context
- Example 4Overflow clipping a dialog
- Example 5Fixed cannot escape stacking
- Example 6The stacking context trap
- Example 7Fixing it with createPortal
- Example 8Portals and React behavior
- Example 9Portals and DOM behavior