@mui/x-charts
Version:
The community edition of MUI X Charts components.
14 lines (12 loc) • 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;
}