UNPKG

@lomray/react-mobx-manager

Version:
3 lines (2 loc) 1.1 kB
import{useConsistentSuspense as e,useId as t}from"@lomray/consistent-suspense";import o from"hoist-non-react-statics";import{observer as r}from"mobx-react-lite";import s,{useState as a,useEffect as n}from"react";import{useStoreManager as m,useStoreManagerParent as c,StoreManagerParentProvider as i}from"./context.js";const l=(l,u,{customContextId:p}={})=>{const S=r(l),b=p||l.libStoreContextId,d=l.displayName||l.name,x=o=>{const r=m(),l=c(),{suspenseId:p}=e(),x=t(),[{contextId:f,hasFailure:h,touchableStores:I,componentStores:y,mountStores:j}]=a((()=>{const e=b||x,t=r.createStores(Object.entries(u),l,e,p,d,o),{globalStores:s,relativeStores:a,parentStores:n,hasCreationFailure:m}=t,c={...a,...s};return{contextId:e,hasFailure:m,touchableStores:c,componentStores:{...c,...n},mountStores:()=>r.mountStores(e,t)}}));return n(j,[j]),s.createElement(i,{parentId:f,touchableStores:I},!h&&s.createElement(S,{...o,...y}))};return o(x,l),x.displayName=`Mobx(${d})`,Object.defineProperty(x,"name",{value:x.displayName,writable:!1,enumerable:!1})};export{l as default}; //# sourceMappingURL=with-stores.js.map