Files
ETB/ETB-FrontEnd/node_modules/@mui/x-charts/esm/hooks/useIsHydrated.js
Iliyan Angelov 306b20e24a Frontend start
2025-09-14 00:54:48 +03:00

14 lines
521 B
JavaScript

'use client';
import * as React from 'react';
/** Returns true after hydration is done on the client.
*
* Basically a implementation of Option 2 of this gist: https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85#option-2-lazily-show-component-with-uselayouteffect. */
export function useIsHydrated() {
const [isHydrated, setIsHydrated] = React.useState(typeof window !== 'undefined' || process.env.NODE_ENV === 'test');
React.useEffect(() => {
setIsHydrated(true);
}, []);
return isHydrated;
}