MCPcopy Index your code
hub / github.com/react/react / useState

Function useState

packages/react-reconciler/src/ReactFiberHooks.js:4096–4108  ·  view source on GitHub ↗
(
      initialState: (() => S) | S,
    )

Source from the content-addressed store, hash-verified

4094 return mountRef(initialValue);
4095 },
4096 useState<S>(
4097 initialState: (() => S) | S,
4098 ): [S, Dispatch<BasicStateAction<S>>] {
4099 currentHookNameInDev = 'useState';
4100 mountHookTypesDev();
4101 const prevDispatcher = ReactSharedInternals.H;
4102 ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV;
4103 try {
4104 return mountState(initialState);
4105 } finally {
4106 ReactSharedInternals.H = prevDispatcher;
4107 }
4108 },
4109 useDebugValue<T>(value: T, formatterFn: ?(value: T) => mixed): void {
4110 currentHookNameInDev = 'useDebugValue';
4111 mountHookTypesDev();

Callers 15

FooFunction · 0.50
ChildFunction · 0.50
Activity-test.jsFile · 0.50
CounterFunction · 0.50
ScrollViewFunction · 0.50
FooFunction · 0.50
BarFunction · 0.50
AppFunction · 0.50
LayoutEffectFunction · 0.50
ParentFunction · 0.50
ChildFunction · 0.50

Calls

no outgoing calls

Tested by 15

FooFunction · 0.40
ChildFunction · 0.40
CounterFunction · 0.40
ScrollViewFunction · 0.40
FooFunction · 0.40
BarFunction · 0.40
AppFunction · 0.40
LayoutEffectFunction · 0.40
ParentFunction · 0.40
ChildFunction · 0.40
NotInsertionFunction · 0.40
LazyComputeFunction · 0.40