createBoundedUseStore
constcreateBoundedUseStore: <S>(store) => {():ExtractState<S>; <T>(selector):T; }
Defined in: packages/pulsar-core/src/utils/createBoundedUseStore.ts:34
Creates a bounded useStore hook from a vanilla Zustand store.
This function takes a vanilla Zustand store instance and returns a React hook that is pre-bound to that store. This approach provides a cleaner API and enhances type inference, eliminating the need to pass the store instance on every use.
The returned hook supports two signatures:
useBoundedStore(): Selects the entire state.useBoundedStore(selector): Selects a slice of the state, returning only what the selector function specifies.
Type Parameters
S
S extends StoreApi<unknown>
The type of the Zustand store (StoreApi).
Parameters
store
S
The vanilla Zustand store instance to bind the hook to.
Returns
A fully typed React hook for accessing the store’s state.
{(): ExtractState<S>; <T>(selector): T; }
Last updated on