facebook/reactMITd083ec1Report / request removal

Public API Reference

The react package exposes element construction, child utilities, hooks, and related component helpers. The excerpts here directly show Children, createElement, and the hook functions that forward work to React’s internal dispatcher.

This surface exists to separate declarative component code from renderer-specific work. Hooks resolve their current dispatcher at call time, while element creation and child helpers provide values that a renderer can later interpret.

Sources: packages/react/src/ReactClient.js:68-74, packages/react/src/jsx/ReactJSXElement.js:606-611, packages/react/src/ReactHooks.js:66-71, packages/react/src/ReactHooks.js:24-42

Core concepts

Hooks

A hook is a function that obtains component behavior through the current dispatcher rather than implementing that behavior directly. useState, useReducer, useRef, useEffect, useInsertionEffect, useLayoutEffect, useCallback, useMemo, useImperativeHandle, useDebugValue, useTransition, useDeferredValue, useId, useSyncExternalStore, useCacheRefresh, use, useMemoCache, useEffectEvent, useOptimistic, and useActionState all use this dispatcher pattern.

Sources: packages/react/src/ReactHooks.js:66-71, packages/react/src/ReactHooks.js:73-80, packages/react/src/ReactHooks.js:82-85, packages/react/src/ReactHooks.js:87-101, packages/react/src/ReactHooks.js:103-117, packages/react/src/ReactHooks.js:119-133, packages/react/src/ReactHooks.js:135-141, packages/react/src/ReactHooks.js:143-149, packages/react/src/ReactHooks.js:151-158, packages/react/src/ReactHooks.js:160-168, packages/react/src/ReactHooks.js:170-176, packages/react/src/ReactHooks.js:178-181, packages/react/src/ReactHooks.js:183-186, packages/react/src/ReactHooks.js:188-199, packages/react/src/ReactHooks.js:201-205, packages/react/src/ReactHooks.js:207-210, packages/react/src/ReactHooks.js:212-216, packages/react/src/ReactHooks.js:218-224, packages/react/src/ReactHooks.js:226-232, packages/react/src/ReactHooks.js:234-241

Dispatcher

The dispatcher is the internal implementation selected through ReactSharedInternals.H; resolveDispatcher retrieves it and reports an invalid hook call in development when it is missing.

Sources: packages/react/src/ReactHooks.js:24-42

Element factory

An element factory creates and returns a ReactElement; the shown implementation is createElement.

Sources: packages/react/src/jsx/ReactJSXElement.js:606-611

Child utility collection

A child utility collection groups operations for transforming or inspecting children; Children contains map, forEach, count, toArray, and only.

Sources: packages/react/src/ReactClient.js:68-74

Component wrappers

A component wrapper changes how another component-like value is represented; the shown server entrypoints import forwardRef, lazy, and memo from ReactForwardRef, ReactLazy, and ReactMemo.

Sources: packages/react/src/ReactServer.js:27-31

How the exported surface is organized

The hook exports are thin public entrypoints. Most first resolve the dispatcher and then call the corresponding dispatcher method, which keeps the public API stable while allowing the active rendering implementation to vary.

Export groupPublic namesWhat the shown code does
StateuseState, useReducerResolve the dispatcher and delegate state operations.
ReferencesuseRef, useImperativeHandleResolve the dispatcher and delegate reference behavior.
EffectsuseEffect, useInsertionEffect, useLayoutEffectValidate the callback in development, then delegate.
MemoizationuseCallback, useMemoResolve the dispatcher and delegate memoization.
Scheduling and identityuseTransition, useDeferredValue, useIdResolve the dispatcher and delegate transition, deferral, or ID behavior.
External and advanced hooksuseSyncExternalStore, useCacheRefresh, use, useMemoCache, useEffectEvent, useOptimistic, useActionStateResolve the dispatcher and delegate the requested operation.

Some hooks add development-only validation before delegation. useEffect, useInsertionEffect, and useLayoutEffect warn when their callback is missing; useContext warns when passed a consumer object instead of the context itself.

useDebugValue is also development-gated: it resolves the dispatcher and delegates only inside the __DEV__ branch.

Sources: packages/react/src/ReactHooks.js:66-71, packages/react/src/ReactHooks.js:73-80, packages/react/src/ReactHooks.js:82-85, packages/react/src/ReactHooks.js:135-141, packages/react/src/ReactHooks.js:143-149, packages/react/src/ReactHooks.js:170-176, packages/react/src/ReactHooks.js:178-181, packages/react/src/ReactHooks.js:183-186, packages/react/src/ReactHooks.js:188-199, packages/react/src/ReactHooks.js:207-210, packages/react/src/ReactHooks.js:226-232, packages/react/src/ReactHooks.js:234-241, packages/react/src/ReactHooks.js:87-101, packages/react/src/ReactHooks.js:103-117, packages/react/src/ReactHooks.js:119-133, packages/react/src/ReactHooks.js:151-158, packages/react/src/ReactHooks.js:201-205, packages/react/src/ReactHooks.js:212-216, packages/react/src/ReactHooks.js:218-224, packages/react/src/ReactHooks.js:53-64, packages/react/src/ReactHooks.js:160-168

How hook calls reach rendering state

A hook call follows a short path: the public hook resolves the current dispatcher, then invokes the matching dispatcher method. If the dispatcher is absent, development builds report an invalid hook call, while the implementation deliberately avoids adding its own production error path.

Hook dispatch path — How does a public hook reach its implementation?

Evidence

The dispatcher itself is selected through ReactSharedInternals.H, so the public hook does not choose a mount, update, or other implementation directly in the shown file.

Sources: packages/react/src/ReactHooks.js:24-42, packages/react/src/ReactHooks.js:66-71

Element creation, children, and wrappers

createElement is implemented in packages/react/src/jsx/ReactJSXElement.js, where its documented purpose is to create and return a new ReactElement. The supplied benchmark excerpts show it used as React.createElement to construct nested elements and component calls, but they do not provide the complete public entrypoint export list.

Children is a named collection rather than a hook. Its five members are map, forEach, count, toArray, and only, so child operations are grouped behind one exported object.

The server entrypoints show where several wrapper exports are implemented: forwardRef comes from ./ReactForwardRef, lazy comes from ./ReactLazy, and memo comes from ./ReactMemo. The excerpts identify these implementation modules but do not show the internal wrapping algorithms, so this page does not infer what values memo or lazy contain beyond their entrypoint wiring.

Sources: packages/react/src/jsx/ReactJSXElement.js:606-611, scripts/bench/benchmarks/pe-functional-components/benchmark.js:1950-1972, packages/react/src/ReactClient.js:68-74, packages/react/src/ReactServer.js:27-31

What belongs to react versus react-dom

The shown evidence places the hook functions under packages/react/src/ReactHooks.js, Children under packages/react/src/ReactClient.js, and createElement under packages/react/src/jsx/ReactJSXElement.js.

The supplied excerpts do not include a react-dom public entrypoint export list, so they cannot establish a complete react-versus-react-dom inventory. They do show react-dom-bindings being re-exported by React Flight client configuration modules, which is renderer/configuration wiring rather than proof of the ordinary react-dom package API.

Sources: packages/react/src/ReactClient.js:68-74, packages/react/src/ReactHooks.js:66-71, packages/react/src/jsx/ReactJSXElement.js:606-611, packages/react-client/src/forks/ReactFlightClientConfig.dom-bun.js:10-16

How it connects

The public hooks hand off to the reconciler’s active dispatcher through ReactSharedInternals.H; the shown API layer does not contain the hook state queues or render-phase algorithms. This is the boundary explained in Hooks Implementation.

createElement produces the element value consumed by component and reconciliation logic, while the broader element contract is covered in Element Types & Components.

Children groups child operations used when handling component children. Their relationship to element construction and tree processing belongs with Reconciliation Algorithm.

The wrapper entrypoints connect forwardRef, lazy, and memo to their implementation modules. Their runtime effects connect to Refs & Forwarding, Suspense & Error Boundaries, and Concurrent Features & Transitions only where those pages document the corresponding behavior.

Sources: packages/react/src/ReactHooks.js:24-42, packages/react/src/ReactHooks.js:66-71, packages/react/src/jsx/ReactJSXElement.js:606-611, packages/react/src/ReactClient.js:68-74, packages/react/src/ReactServer.js:27-31

Key takeaways

  • react exposes hooks that resolve a dispatcher and delegate to it.
  • Children is an object containing five child utilities.
  • createElement creates and returns a ReactElement.
  • memo, lazy, and forwardRef are wired to dedicated implementation modules.
  • The supplied excerpts do not prove a complete react-dom export inventory.

Want this for your repos?

Try Angada AI Wiki