Loading
A React tool that lets a component remember a value between renders — like a whiteboard that keeps your notes even when the room gets repainted.
A hook that returns a [value, setter] tuple, triggering a re-render when the setter is called with a new value. State updates are batched and applied asynchronously during the next render cycle.
useState allocates a hook slot on the component's fiber, linked via a singly-linked list in call order. The dispatch function enqueues an update object onto the hook's queue; during rendering, the reducer (basicStateReducer) processes queued updates to produce the next state. Functional updaters (setState(prev => next)) are essential when updates depend on current state, as they are applied sequentially from the base state.