State
/ API Reference
State
/ API Reference

useStoreFactory

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

ArgumentTypeDescription
useStateFunctionA 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)()
On this page