function useSelector<TSource, TSelected>(
source,
selector,
options?): TSelected;
function useSelector<TSource, TSelected>(
source,
selector,
options?): TSelected;
Defined in: packages/react-store/src/useSelector.ts:43
Selects a slice of state from an atom or store and subscribes the component to that selection.
This is the primary React read hook for TanStack Store. It works with any source that exposes get() and subscribe(), including atoms, readonly atoms, stores, and readonly stores.
Omit the selector to subscribe to the whole value.
TSource
TSelected = NoInfer<TSource>
SelectionSource<TSource>
(snapshot) => TSelected
UseSelectorOptions<TSelected>
TSelected
const count = useSelector(counterStore, (state) => state.count)
const count = useSelector(counterStore, (state) => state.count)
const value = useSelector(countAtom)
const value = useSelector(countAtom)
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.