UNPKG

jotai

Version:

👻 Primitive and flexible state management for React

2 lines (1 loc) • 760 B
System.register(["react","jotai/react","jotai/vanilla/utils","jotai/vanilla"],function(k){"use strict";var c,i,r,m,l,A,f;return{setters:[function(e){c=e.useCallback,i=e.useMemo},function(e){r=e.useSetAtom,m=e.useAtom,l=e.useStore},function(e){A=e.RESET},function(e){f=e.atom}],execute:function(){k({useAtomCallback:b,useHydrateAtoms:C,useReducerAtom:R,useResetAtom:e});function e(s,t){const n=r(s,t);return c(()=>n(A),[n])}function R(s,t,n){const[u,o]=m(s,n),a=c(d=>{o(j=>t(j,d))},[o,t]);return[u,a]}function b(s,t){const n=i(()=>f(null,(u,o,...a)=>s(u,o,...a)),[s]);return r(n,t)}const S=new WeakMap;function C(s,t){const n=l(t),u=E(n);for(const[o,a]of s)u.has(o)||(u.add(o),n.set(o,a))}const E=s=>{let t=S.get(s);return t||(t=new WeakSet,S.set(s,t)),t}}}});