useHasMounted
should be used when conditionally rendering components or styles in SSR or SSG environments.
We recommend using useHasMounted
whenever you use useBreakpoints or any other hooks that rely on the window object to conditionally render content. This combination can be used to prevent cumulative layout shifts (CLS). This is called two pass rendering and ensures that the component has been mounted and the window object is present before painting the DOM.
Basic usage
Loading...
Preventing Hydration Mismatch
Loading...