UNPKG

@ledgerhq/live-common

Version:
18 lines 657 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = require("react"); // Stateless hook that returns a function which, when called, indicates if the component // using the hook is currently mounted or not const useIsMounted = () => { const mountedRef = (0, react_1.useRef)(false); const isMounted = (0, react_1.useCallback)(() => mountedRef.current, []); (0, react_1.useEffect)(() => { mountedRef.current = true; return () => { mountedRef.current = false; }; }, []); return isMounted; }; exports.default = useIsMounted; //# sourceMappingURL=useIsMounted.js.map