v4.4.2
This release adds a new hook to the optional ui-react module called useProvideStore.
This lets you add a Store object by Id to a Provider component, but imperatively from a component within it. For example:
const App = () => (
<Provider>
<RegisterStore />
<ConsumeStore />
</Provider>
);
const RegisterStore = () => {
const store = useCreateStore(() =>
createStore().setCell('pets', 'fido', 'color', 'brown'),
);
useProvideStore('petStore', store);
return null;
};
const ConsumeStore = () => (
<span>{JSON.stringify(useStore('petStore')?.getTableIds())}</span>
);