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

Function finishClassComponent

packages/react-server/src/ReactFizzServer.js:2362–2415  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  keyPath: KeyNode,
  instance: any,
  Component: any,
  props: any,
)

Source from the content-addressed store, hash-verified

2360}
2361
2362function finishClassComponent(
2363 request: Request,
2364 task: Task,
2365 keyPath: KeyNode,
2366 instance: any,
2367 Component: any,
2368 props: any,
2369): ReactNodeList {
2370 let nextChildren;
2371 if (__DEV__) {
2372 nextChildren = (callRenderInDEV(instance): any);
2373 } else {
2374 nextChildren = instance.render();
2375 }
2376 if (request.status === ABORTING) {
2377 // eslint-disable-next-line no-throw-literal
2378 throw null;
2379 }
2380
2381 if (__DEV__) {
2382 if (instance.props !== props) {
2383 if (!didWarnAboutReassigningProps) {
2384 console.error(
2385 'It looks like %s is reassigning its own `this.props` while rendering. ' +
2386 'This is not supported and can lead to confusing bugs.',
2387 getComponentNameFromType(Component) || 'a component',
2388 );
2389 }
2390 didWarnAboutReassigningProps = true;
2391 }
2392 }
2393
2394 if (!disableLegacyContext) {
2395 const childContextTypes = Component.childContextTypes;
2396 if (childContextTypes !== null && childContextTypes !== undefined) {
2397 const previousContext = task.legacyContext;
2398 const mergedContext = processChildContext(
2399 instance,
2400 Component,
2401 previousContext,
2402 childContextTypes,
2403 );
2404 task.legacyContext = mergedContext;
2405 renderNodeDestructive(request, task, nextChildren, -1);
2406 task.legacyContext = previousContext;
2407 return;
2408 }
2409 }
2410
2411 const prevKeyPath = task.keyPath;
2412 task.keyPath = keyPath;
2413 renderNodeDestructive(request, task, nextChildren, -1);
2414 task.keyPath = prevKeyPath;
2415}
2416
2417export function resolveClassComponentProps(
2418 Component: any,

Callers 1

renderClassComponentFunction · 0.70

Calls 5

processChildContextFunction · 0.90
getComponentNameFromTypeFunction · 0.85
renderNodeDestructiveFunction · 0.85
renderMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected