State
/ API ReferenceState
/ API ReferenceuseStoreFactory
useStoreFactory is the core factory function that creates store hooks. It's used internally by useStore and useOptimisticStore, but can also be used to create custom store implementations.
Arguments
| Argument | Type | Description |
|---|---|---|
| useState | Function | A useState-like hook that takes an initial state and returns [state, setState] |
Returns
(Function) A function that takes middleware and returns a useStore hook.
Example
import { useStoreFactory } from '@weser/state'
import { useState } from 'react'
const useStore = useStoreFactory(useState)()
© 2024-present Robin Weser. All Rights Reserved.