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

Function renderFunctionComponent

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

Source from the content-addressed store, hash-verified

2485let didWarnAboutMaps = false;
2486
2487function renderFunctionComponent(
2488 request: Request,
2489 task: Task,
2490 keyPath: KeyNode,
2491 Component: any,
2492 props: any,
2493): void {
2494 let legacyContext;
2495 if (!disableLegacyContext && !disableLegacyContextForFunctionComponents) {
2496 legacyContext = getMaskedContext(Component, task.legacyContext);
2497 }
2498 if (__DEV__) {
2499 if (
2500 Component.prototype &&
2501 typeof Component.prototype.render === 'function'
2502 ) {
2503 const componentName = getComponentNameFromType(Component) || 'Unknown';
2504
2505 if (!didWarnAboutBadClass[componentName]) {
2506 console.error(
2507 "The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
2508 'This is likely to cause errors. Change %s to extend React.Component instead.',
2509 componentName,
2510 componentName,
2511 );
2512 didWarnAboutBadClass[componentName] = true;
2513 }
2514 }
2515 }
2516
2517 const value = renderWithHooks(
2518 request,
2519 task,
2520 keyPath,
2521 Component,
2522 props,
2523 legacyContext,
2524 );
2525 if (request.status === ABORTING) {
2526 // eslint-disable-next-line no-throw-literal
2527 throw null;
2528 }
2529
2530 const hasId = checkDidRenderIdHook();
2531 const actionStateCount = getActionStateCount();
2532 const actionStateMatchingIndex = getActionStateMatchingIndex();
2533
2534 if (__DEV__) {
2535 if (Component.contextTypes) {
2536 const componentName = getComponentNameFromType(Component) || 'Unknown';
2537 if (!didWarnAboutContextTypes[componentName]) {
2538 didWarnAboutContextTypes[componentName] = true;
2539 if (disableLegacyContext) {
2540 console.error(
2541 '%s uses the legacy contextTypes API which was removed in React 19. ' +
2542 'Use React.createContext() with React.useContext() instead. ' +
2543 '(https://react.dev/link/legacy-context)',
2544 componentName,

Callers 1

renderElementFunction · 0.70

Calls 9

getMaskedContextFunction · 0.90
checkDidRenderIdHookFunction · 0.90
getActionStateCountFunction · 0.90
getComponentNameFromTypeFunction · 0.85
renderWithHooksFunction · 0.85
finishFunctionComponentFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected