UNPKG

@react-hookbox/after-loading-effect

Version:
27 lines (22 loc) 953 B
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : (global = global || self, factory(global.afterLoadingEffect = {}, global.react)); }(this, (function (exports, react) { var useAfterLoadingEffect = function useAfterLoadingEffect(isLoading, callback, useEffectHook) { if (useEffectHook === void 0) { useEffectHook = react.useEffect; } var wasLoadingRef = react.useRef(isLoading); useEffectHook(function () { if (wasLoadingRef.current && !isLoading) { wasLoadingRef.current = isLoading; return callback(); } wasLoadingRef.current = isLoading; }, [isLoading, callback]); }; exports.default = useAfterLoadingEffect; exports.useAfterLoadingEffect = useAfterLoadingEffect; }))); //# sourceMappingURL=index.umd.js.map