MCPcopy
hub / github.com/facebook/react / useState

Function useState

packages/react-server/src/ReactFizzHooks.js:345–356  ·  view source on GitHub ↗
(
  initialState: (() => S) | S,
)

Source from the content-addressed store, hash-verified

343}
344
345export function useState<S>(
346 initialState: (() => S) | S,
347): [S, Dispatch<BasicStateAction<S>>] {
348 if (__DEV__) {
349 currentHookNameInDev = 'useState';
350 }
351 return useReducer(
352 basicStateReducer,
353 // useReducer has a special case to support lazy useState initializers
354 (initialState: any),
355 );
356}
357
358export function useReducer<S, I, A>(
359 reducer: (S, A) => S,

Callers

nothing calls this directly

Calls 1

useReducerFunction · 0.70

Tested by

no test coverage detected