@prezly/react-promise-modal
Version:
The proper (and easy) way of doing modals in React. With Promises.
23 lines (22 loc) • 646 B
JavaScript
;
var _react = require("react");
var React = _react;
/**
* @see https://streamich.github.io/react-use/?path=/story/lifecycle-usemountedstate--docs
*
* Lifecycle hook providing ability to check component's mount status.
* Returns a function that will return true if component mounted and false otherwise.
*/
function useIsMounted() {
var isMounted = React.useRef(false);
React.useEffect(function () {
isMounted.current = true;
return function () {
isMounted.current = false;
};
}, []);
return React.useCallback(function () {
return isMounted.current;
}, []);
}
exports.useIsMounted = useIsMounted;