useSetState

Keep an object in state and update it with partial changes, like the setState of a class component.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

Changing one field keeps the others.

APIs

useSetState

const useSetState = <T extends Record<string, unknown>>(
  initialState: T,
) => [
  T,
  (partial: Partial<T> | ((current: T) => Partial<T>)) => void,
]
Edit this page on GitHub