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

Function finishHooks

packages/react-server/src/ReactFizzHooks.js:243–272  ·  view source on GitHub ↗
(
  Component: any,
  props: any,
  children: any,
  refOrContext: any,
)

Source from the content-addressed store, hash-verified

241}
242
243export function finishHooks(
244 Component: any,
245 props: any,
246 children: any,
247 refOrContext: any,
248): any {
249 // This must be called after every function component to prevent hooks from
250 // being used in classes.
251
252 while (didScheduleRenderPhaseUpdate) {
253 // Updates were scheduled during the render phase. They are stored in
254 // the `renderPhaseUpdates` map. Call the component again, reusing the
255 // work-in-progress hooks and applying the additional updates on top. Keep
256 // restarting until no more updates are scheduled.
257 didScheduleRenderPhaseUpdate = false;
258 localIdCounter = 0;
259 actionStateCounter = 0;
260 actionStateMatchingIndex = -1;
261 thenableIndexCounter = 0;
262 numberOfReRenders += 1;
263
264 // Start over from the beginning of the list
265 workInProgressHook = null;
266
267 children = Component(props, refOrContext);
268 }
269
270 resetHooksState();
271 return children;
272}
273
274export function getThenableStateAfterSuspending(): null | ThenableState {
275 const state = thenableState;

Callers 1

renderWithHooksFunction · 0.90

Calls 2

resetHooksStateFunction · 0.85
ComponentFunction · 0.50

Tested by

no test coverage detected