Founding price: $35, then $99 after 23:59 UTC on 4 November, then $99
Get ProA function that tells you whether the component is still mounted, to skip state updates after an async call finishes late.
This item has no props to tune. Use the lens above to change theme, density, direction and more.
Use it to guard a state update that runs after an await or a timer when the component may have unmounted in the meantime.
Do not use it to pick what to render on the first client render; for that, render the same markup on the server and the client and update in an effect. Prefer an AbortController for fetches when you can.
import { useIsMounted } from "@/hooks/use-is-mounted"const isMounted = useIsMounted()
async function load() {
const data = await fetchData()
if (isMounted()) setData(data)
}useIsMounted(): () => boolean
The returned function has a stable identity. It is false during the first render and on the server, true after the component mounts, and false again after it unmounts.
A hook has no markup and no accessibility surface of its own.
The hook ships with renderHook tests (use-is-mounted.test.ts) covering its behaviour, cleanup on unmount and server-safe defaults. It is safe to render on the server.