Reference
useStore
Atom<TState> | ReadonlyAtom<TState>
The store atom to subscribe to.
(state: TState) => TSelected
default:"(d) => d"
Optional function that selects a slice of state from the atom. Defaults to returning the entire state.
UseStoreOptions<TSelected>
Optional configuration object.
Returns
Accessor<TSelected>
A Solid.js signal accessor function that returns the selected state value.
Usage
Basic Usage
Selecting Multiple Values
Custom Equality Function
Using Entire State
With Derived State
With Show Component
Notes
- Returns a Solid.js signal accessor - call it as a function to get the value
- Uses
createSignalinternally for fine-grained reactivity - Automatically cleans up subscriptions using
onCleanup - Defaults to
shallowequality comparison for optimal performance - The selector is evaluated immediately on creation and on each update
- Integrates seamlessly with Solid’s reactive primitives like
createMemo,createEffect, etc.