API Reference

The hooks and top-level APIs that constitute React's public surface.

Path: api-reference

Third-party documentation. This is independently authored analysis of the public React codebase — not the official docs, and not reviewed or endorsed by the React team.

API Reference

React's exported surface is small by design; the hooks are the bulk of it.

State and effects

  • useState(initial) — local state; setter accepts values or updater functions.
  • useReducer(reducer, initialArg) — reducer-style state for multi-step transitions.
  • useEffect(fn, deps?) — synchronize with external systems; return a cleanup function.
  • useLayoutEffect(fn, deps?) — like useEffect but fires synchronously after DOM mutations, before paint.

Values and memoization

  • useMemo(fn, deps) / useCallback(fn, deps) — cache computations/references across renders.
  • useRef(initial) — mutable box that survives renders; also the DOM-node handle via ref props.
  • useContext(Ctx) — read the nearest provider's value.

Concurrency and transitions

  • useTransition() — mark updates as non-urgent; returns [isPending, startTransition].
  • useDeferredValue(value) — render with a lagging copy of a fast-changing value.
  • useId() — stable unique ids safe across server/client rendering.
  • useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot?) — external store bridge.

Top-level APIs

  • createRoot(node), hydrateRoot(node, element) — client entry points (react-dom).
  • createContext(default) — context object factory.
  • memo(Component), forwardRef(render), lazy(loader), Suspense — component-level optimization and code-splitting primitives.

Interface

Interface
typescript
// State & lifecycle
function useState<S>(initial: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
function useEffect(effect: () => void | Cleanup, deps?: unknown[]): void;
function useLayoutEffect(effect: Effect, deps?: unknown[]): void;
 
// Values across renders & trees
const value = useContext(Ctx);
const memo = useMemo<T>(() => compute, deps);
const cached = useCallback<F>(fn, deps);
const ref = useRef<T>(initial);
 
// Context
const Ctx = createContext<T>(default);
<Ctx.Provider value={value}>…</Ctx.Provider>
 
// Top-level
createRoot(container).render(<App />);
 
STATUSinterface