@acoolhq/react-tiny-store / useStoreSelector
Function: useStoreSelector()
useStoreSelector<
T,S>(store,selector,isEqual):S
Defined in: hooks.ts:37
Selects a derived value from a store with granular re-renders.
Type Parameters
T
T
Root state shape.
S
S
Selected slice shape.
Parameters
store
Store<T>
The external store instance.
selector
(root) => S
Pure selector (root) => slice.
isEqual
(a, b) => boolean
Optional equality to suppress updates (default Object.is).
Returns
S
The selected value S, updated only when isEqual(prev, next) is false.
Example
ts
const count = useStoreSelector(store, s => s.todos.length);