Skip to main content

useIsMounted

A custom hook to check whether a Component is mounted in the browser.

It can also be used in SSR environments to guarantee that the actual component is mounted in the browser. (Feat. Hydration Error)


Interface

const useIsMounted: () => boolean

Usage

import { useIsMounted } from '@devgrace/react';

const Example = () => {
const isMounted = useIsMounted();

return <div>{isMounted ? 'done' : 'in progress'}</div>;
};