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

Function renderWithHooks

packages/react-server/src/ReactFizzServer.js:2332–2360  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  keyPath: KeyNode,
  Component: (p: Props, arg: SecondArg) => any,
  props: Props,
  secondArg: SecondArg,
)

Source from the content-addressed store, hash-verified

2330}
2331
2332function renderWithHooks<Props, SecondArg>(
2333 request: Request,
2334 task: Task,
2335 keyPath: KeyNode,
2336 Component: (p: Props, arg: SecondArg) => any,
2337 props: Props,
2338 secondArg: SecondArg,
2339): any {
2340 // Reset the task's thenable state before continuing, so that if a later
2341 // component suspends we can reuse the same task object. If the same
2342 // component suspends again, the thenable state will be restored.
2343 const prevThenableState = task.thenableState;
2344 task.thenableState = null;
2345 const componentIdentity = {};
2346 prepareToUseHooks(
2347 request,
2348 task,
2349 keyPath,
2350 componentIdentity,
2351 prevThenableState,
2352 );
2353 let result;
2354 if (__DEV__) {
2355 result = callComponentInDEV(Component, props, secondArg);
2356 } else {
2357 result = Component(props, secondArg);
2358 }
2359 return finishHooks(Component, props, result, secondArg);
2360}
2361
2362function finishClassComponent(
2363 request: Request,

Callers 5

renderFunctionComponentFunction · 0.85
renderForwardRefFunction · 0.85
updateForwardRefFunction · 0.85
updateFunctionComponentFunction · 0.85
ReactFiberHooks.jsFile · 0.85

Calls 3

prepareToUseHooksFunction · 0.90
finishHooksFunction · 0.90
ComponentFunction · 0.50

Tested by

no test coverage detected