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

Function renderFunctionComponent

packages/react-server/src/ReactFlightServer.js:1585–1771  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  key: null | string,
  Component: (p: Props, arg: void) => any,
  props: Props,
  validated: number, // DEV-only
)

Source from the content-addressed store, hash-verified

1583}
1584
1585function renderFunctionComponent<Props>(
1586 request: Request,
1587 task: Task,
1588 key: null | string,
1589 Component: (p: Props, arg: void) => any,
1590 props: Props,
1591 validated: number, // DEV-only
1592): ReactJSONValue {
1593 // Reset the task's thenable state before continuing, so that if a later
1594 // component suspends we can reuse the same task object. If the same
1595 // component suspends again, the thenable state will be restored.
1596 const prevThenableState = task.thenableState;
1597 task.thenableState = null;
1598
1599 let result;
1600
1601 let componentDebugInfo: ReactComponentInfo;
1602 if (__DEV__) {
1603 if (!canEmitDebugInfo) {
1604 // We don't have a chunk to assign debug info. We need to outline this
1605 // component to assign it an ID.
1606 return outlineTask(request, task);
1607 } else if (prevThenableState !== null) {
1608 // This is a replay and we've already emitted the debug info of this component
1609 // in the first pass. We skip emitting a duplicate line.
1610 // As a hack we stashed the previous component debug info on this object in DEV.
1611 componentDebugInfo = (prevThenableState: any)._componentDebugInfo;
1612 } else {
1613 // This is a new component in the same task so we can emit more debug info.
1614 const componentDebugID = task.id;
1615 const componentName =
1616 (Component: any).displayName || Component.name || '';
1617 const componentEnv = (0, request.environmentName)();
1618 request.pendingChunks++;
1619 componentDebugInfo = ({
1620 name: componentName,
1621 env: componentEnv,
1622 key: key,
1623 owner: task.debugOwner,
1624 }: ReactComponentInfo);
1625 // $FlowFixMe[cannot-write]
1626 componentDebugInfo.stack =
1627 task.debugStack === null
1628 ? null
1629 : filterStackTrace(request, parseStackTrace(task.debugStack, 1));
1630 // $FlowFixMe[cannot-write]
1631 componentDebugInfo.props = props;
1632 // $FlowFixMe[cannot-write]
1633 componentDebugInfo.debugStack = task.debugStack;
1634 // $FlowFixMe[cannot-write]
1635 componentDebugInfo.debugTask = task.debugTask;
1636
1637 // We outline this model eagerly so that we can refer to by reference as an owner.
1638 // If we had a smarter way to dedupe we might not have to do this if there ends up
1639 // being no references to this as an owner.
1640
1641 outlineComponentInfo(request, componentDebugInfo);
1642

Callers 1

renderElementFunction · 0.70

Calls 15

isClientReferenceFunction · 0.90
outlineTaskFunction · 0.85
filterStackTraceFunction · 0.85
outlineComponentInfoFunction · 0.85
advanceTaskTimeFunction · 0.85
emitDebugChunkFunction · 0.85
renderModelDestructiveFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected