function useSelector<TSource, TSelected>(
source,
selector,
options?): Accessor<TSelected>;
function useSelector<TSource, TSelected>(
source,
selector,
options?): Accessor<TSelected>;
Defined in: solid-store/src/useSelector.ts:40
Selects a slice of state from an atom or store and subscribes the component to that selection.
This is the primary Solid read hook for TanStack Store. It returns a Solid accessor so consumers can read the selected value reactively.
Omit the selector to subscribe to the whole value.
TSource
TSelected = NoInfer<TSource>
SelectionSource<TSource>
(snapshot) => TSelected
UseSelectorOptions<TSelected>
Accessor<TSelected>
const count = useSelector(counterStore, (state) => state.count)
return <p>{count()}</p>
const count = useSelector(counterStore, (state) => state.count)
return <p>{count()}</p>
const value = useSelector(countAtom)
const value = useSelector(countAtom)
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.