const useUpdateState: <T>(
initialState: Initial<T>,
useStateHook?: UseState,
) => Pair<T>
useState
with an updateState
instead of a setState
. Uses patch
to apply updates.
const [state, updateState] = useUpdateState({ ... });
When combined with useCursor
, this allows for zero-hassle state management.
Compose this hook with other useState
variants using useStateHook
, e.g. the classic useLocalStorage
that saves to browser local storage.
packages / state / src / hooks-live.ts