@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
18 lines • 657 B
JavaScript
;
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