useMounted — 마운트 훅
SSR에 안전한 플래그로, 컴포넌트가 클라이언트에서 마운트되면 true로 바뀌어요.
출처: 문서
본문
사용법 (Usage)
import { useMounted } from '@primereact/hooks/use-mounted';
const mounted = useMounted();
if (!mounted) return null;
return <ClientOnlyContent />;
하이드레이션 불일치를 일으키지 않고 브라우저 API에 의존하는 콘텐츠를 게이트할 때 유용해요.
옵션 (Options)
useMounted({
onMounted: () => console.log('mounted'),
onUnmounted: () => console.log('unmounted')
});
두 콜백 모두 선택 사항이에요.
시그니처 (Signature)
function useMounted(options?: { onMounted?: () => void; onUnmounted?: () => void }): boolean;