useIsMounted
A stable getter for whether this hook is currently mounted.
Returns a getter that is false during server rendering and before its mount effect, true while mounted and false after cleanup. Checking it does not cause a render.
Usage
Examples
Playground
API
1 return value
Accessibility
Keep pending, success and cancellation feedback visible to users.
Notes
- This does not cancel work or protect against stale responses after props change. Prefer AbortController or request identity for those cases.
- Use useIsClient for a reactive hydration flag. React Strict Mode replays effects in development.
Related
useIsClientFalse on the server and during hydration, true on the client.useDocumentTitleSet a document title and restore the previous owner on cleanup.useIsMobileTrue below the 768px phone breakpoint.useMediaQueryTrack a CSS media query, SSR-safe.useOnlineStatusWhether the browser reports a network connection.usePageVisibilityWhether the tab is visible, to pause work in the background.