本页还没有译文
本页 20 段还没译成日本語,下面显示的是英文原文。useSelector
还没翻译译自英文(tanstack.com)本页 20 段都还没译
function useSelector<TSource, TSelected>(
source,
selector?,
options?): TSelected;Defined in: node_modules/.pnpm/@tanstack+react-store@0.11.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/@tanstack/react-store/dist/useSelector.d.ts:31
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.
Type Parameters
TSource
TSource
TSelected
TSelected = NoInfer<TSource>
Parameters
source
SelectionSource<TSource>
selector?
(snapshot) => TSelected
options?
UseSelectorOptions<TSelected>
Returns
TSelected
Examples
const count = useSelector(counterStore, (state) => state.count)const value = useSelector(countAtom)AI 翻译查看英文原文