Skip to content

v4.4.2

Choose a tag to compare

@jamesgpearce jamesgpearce released this 15 Nov 04:03
· 1825 commits to main since this release

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>
);