UNPKG

omnipay-savings-sdk

Version:

Omnipay Savings SDK

25 lines (24 loc) 779 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useOnMounted = void 0; const react_1 = require("react"); /** * * @returns a function to prevent displaying the component it is * used in immediately so animation can be a little bit smoother */ function useOnMounted() { const onMounted = (0, react_1.useRef)(false); const [isLoading, setLoading] = (0, react_1.useState)(true); (0, react_1.useEffect)(() => { onMounted.current = true; setTimeout(() => { setLoading(false); }); return () => { onMounted.current = false; }; }, []); return { onMounted: (0, react_1.useCallback)(() => onMounted.current, []), isLoading }; } exports.useOnMounted = useOnMounted;