Store API Reference
- Store
- ReadonlyStore
- Atom
- AtomOptions
- BaseAtom
- InternalBaseAtom
- InternalReadonlyAtom
- InteropSubscribable
- Readable
- ReadonlyAtom
- StoreActionsApi
- Subscribable
- Subscription
- AnyAtom
- Observer
- Selection
- StoreAction
- StoreActionMap
- StoreActionsFactory
- batch
- createAsyncAtom
- createAtom
- createStore
- flush
- shallow
- toObserver
- createStoreContext
- useCreateAtom
- useCreateStore
- useSelector
- useSetValue
- useAtom
- useStoreActions
- _useStore (experimental)
- useStore (deprecated)
- UseSelectorOptions
useCreateStore
Call Signature#
function useCreateStore<T>(getValue): ReadonlyStore<T>;Defined in: packages/react-store/src/useCreateStore.ts:24
Creates a stable store instance for the lifetime of the component.
Pass an initial value to create a writable store, or a getter function to create a readonly derived store. This hook mirrors the overloads from createStore, but ensures the store is only created once per mount.
Type Parameters#
T#
T
Parameters#
getValue#
(prev?) => T
Returns#
ReadonlyStore<T>
Example#
const counterStore = useCreateStore({ count: 0 })Call Signature#
function useCreateStore<T>(initialValue): Store<T>;Defined in: packages/react-store/src/useCreateStore.ts:27
Creates a stable store instance for the lifetime of the component.
Pass an initial value to create a writable store, or a getter function to create a readonly derived store. This hook mirrors the overloads from createStore, but ensures the store is only created once per mount.
Type Parameters#
T#
T
Parameters#
initialValue#
T
Returns#
Store<T>
Example#
const counterStore = useCreateStore({ count: 0 })Call Signature#
function useCreateStore<T, TActions>(initialValue, actions): Store<T, TActions>;Defined in: packages/react-store/src/useCreateStore.ts:28
Creates a stable store instance for the lifetime of the component.
Pass an initial value to create a writable store, or a getter function to create a readonly derived store. This hook mirrors the overloads from createStore, but ensures the store is only created once per mount.
Type Parameters#
T#
T
TActions#
TActions extends StoreActionMap
Parameters#
initialValue#
NonFunction<T>
actions#
StoreActionsFactory<T, TActions>
Returns#
Store<T, TActions>
Example#
const counterStore = useCreateStore({ count: 0 })