Saphyra Docs

createStoreUtils

A function paired with your store definition that makes it easy to integrate with React. It provides several hooks that extract information from the store and translate it in a way React can understand.

Quick overview:

A quick overview of the hooks and utilities provided by createStoreUtils:

Hook/HelperDescription
useCommittedSelectorPass a selector to get a slice of the store state
useSelectorPass a selector to get a slice of the optimistic state
ProviderA Context.Provider to provide the store state to children
useStoreAccess the [store, setStore] tuple provided by the context
useErrorHandlerPass an error handler that runs whenever an error is caught
useTransitionSubscribe to an ongoing transition and derive loading states from it
useLazyValuePass a selector, if the returned value is undefined, run a promise to populate the store and re-run the selector again

On this page