mount and unmount
Mounting is when a component is first added to the page; unmounting is when it is removed.
In more detail
Components set up listeners and state when they mount and must clean them up when they unmount. A dialog that unmounts should return focus to the element that opened it.
Related terms
- useEffect — The React hook for running side work, such as adding listeners or changing document.body, after a component renders.
- focus restoration — Returning keyboard focus to the element that opened an overlay, such as its trigger button, when the overlay closes.
Taught in
- Overlay Architecture: Portals, Stacking Contexts & Backdrops — Design Systems & Component Engineering
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering
- Modal Dialogs & Alert Dialogs: Accessible Overlay Patterns — Design Systems & Component Engineering