UNPKG

@signaldb/react

Version:

SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON in

25 lines (24 loc) 989 B
import { useReducer as c, useRef as s, useMemo as a, useEffect as p } from "react"; const d = (e) => e + 1, f = () => c(d, 0)[1]; function C(e) { function r(o, u) { const i = f(), t = s({ isComponentMounted: !0, hasInitialRender: !1 }), n = () => { t.current.stopComputation && (t.current.stopComputation(), t.current.stopComputation = void 0), t.current.stopComputation = e(() => { t.current.isComponentMounted && (t.current.data = o(), t.current.hasInitialRender && i()); }); }; return a(() => { t.current.isComponentMounted && n(); }, u || []), p(() => (t.current.isComponentMounted = !0, t.current.hasInitialRender = !0, t.current.stopComputation || n(), () => { t.current.isComponentMounted = !1, t.current.stopComputation && (t.current.stopComputation(), t.current.stopComputation = void 0); }), []), t.current.data; } return r; } export { C as createUseReactivityHook }; //# sourceMappingURL=index.mjs.map