Back to Mantine

Use Mounted

apps/mantine.dev/src/pages/hooks/use-mounted.mdx

9.1.1490 B
Original Source

import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx';

export default Layout(MDX_DATA.useMounted);

Usage

The useMounted hook returns true if the component is mounted and false if it's not.

tsx
import { useMounted } from '@mantine/hooks';

function Demo() {
  const mounted = useMounted();
  return (
    <div>
      {mounted ? 'Component is mounted' : 'Component is not mounted'}
    </div>
  );
}

Definition

tsx
function useMounted(): boolean;