UNPKG

react-async-iterators

Version:

The magic of JavaScript async iterators in React ⛓️ 🧬 🔃

26 lines 898 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useEffectStrictModeSafe = useEffectStrictModeSafe; const react_1 = require("react"); function useEffectStrictModeSafe(effect, deps) { const isPendingTeardownRef = (0, react_1.useRef)(false); (0, react_1.useEffect)(() => { const teardown = effect(); if (teardown) { isPendingTeardownRef.current = false; return () => { if (isPendingTeardownRef.current) { return; } isPendingTeardownRef.current = true; (async () => { await undefined; if (isPendingTeardownRef.current) { teardown(); } })(); }; } }, deps); } //# sourceMappingURL=useEffectStrictModeSafe.js.map