unmount
When React removes a component and its DOM nodes from the page, discarding its state.
In more detail
Before a component is removed, React runs the cleanup functions of its effects and clears its refs to null. Anything the component set up, such as listeners or timers, must be released there or it leaks.
Related terms
- mount — When React creates a component for the first time and adds its DOM nodes to the page.
- cleanup function — The function an Effect returns so React can undo what the setup did, such as removing a listener or cancelling a request.
- memory leak — Memory that a program keeps holding although it no longer needs it, so usage grows until the program slows down or crashes.
Taught in
- Keys In Depth: Identity Preservation And Identity Resetting — React 19 & Modern Component Architecture
- Diffing Algorithm: Element Type Shifts And Subtree Tear Down — React 19 & Modern Component Architecture
- useEffect Lifecycle: Mount, Dependencies, And Cleanup Phases — React 19 & Modern Component Architecture
- useRef Mechanics: DOM References And Mutable Persistent State — React 19 & Modern Component Architecture
- Creating Event Listener Hooks with Clean Teardown Logic — React 19 & Modern Component Architecture
- Error Boundaries: componentDidCatch And Fallback UI Trees — React 19 & Modern Component Architecture
- React Portals: Escaping Stacking Contexts for Modals — React 19 & Modern Component Architecture