Loading
The React hook for adding a changeable value to a component. Returns the current value and a function to update it.
Returns `[value, setValue]`. Calling `setValue(next)` queues a re-render with the new value. For objects and arrays, always pass a new reference — mutating the existing one won't trigger a render. Use the functional form (`setValue(prev => ...)`) to avoid stale state bugs.
Backed by a fiber slot. React compares old and new values with `Object.is`. If equal, the render is bailed out. React 18 batches multiple `setState` calls in the same event handler into one re-render.