@mui/x-charts
Version:
The community edition of the charts components (MUI X).
21 lines • 699 B
JavaScript
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
export function useMounted() {
var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var _React$useState = React.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
mountedState = _React$useState2[0],
setMountedState = _React$useState2[1];
useEnhancedEffect(function () {
if (!defer) {
setMountedState(true);
}
}, [defer]);
React.useEffect(function () {
if (defer) {
setMountedState(true);
}
}, [defer]);
return mountedState;
}