@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
3 lines (2 loc) • 1.08 kB
JavaScript
(function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n.SignalDB={},n.React))})(this,function(n,t){"use strict";const u=o=>o+1,i=()=>t.useReducer(u,0)[1];function s(o){function c(p,a){const d=i(),e=t.useRef({isComponentMounted:!0,hasInitialRender:!1}),r=()=>{e.current.stopComputation&&(e.current.stopComputation(),e.current.stopComputation=void 0),e.current.stopComputation=o(()=>{e.current.isComponentMounted&&(e.current.data=p(),e.current.hasInitialRender&&d())})};return t.useMemo(()=>{e.current.isComponentMounted&&r()},a||[]),t.useEffect(()=>(e.current.isComponentMounted=!0,e.current.hasInitialRender=!0,e.current.stopComputation||r(),()=>{e.current.isComponentMounted=!1,e.current.stopComputation&&(e.current.stopComputation(),e.current.stopComputation=void 0)}),[]),e.current.data}return c}n.createUseReactivityHook=s,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map