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

Function outlineComponentInfo

packages/react-server/src/ReactFlightServer.js:4272–4343  ·  view source on GitHub ↗
(
  request: Request,
  componentInfo: ReactComponentInfo,
)

Source from the content-addressed store, hash-verified

4270}
4271
4272function outlineComponentInfo(
4273 request: Request,
4274 componentInfo: ReactComponentInfo,
4275): string {
4276 if (!__DEV__) {
4277 // These errors should never make it into a build so we don't need to encode them in codes.json
4278 // eslint-disable-next-line react-internal/prod-error-codes
4279 throw new Error(
4280 'outlineComponentInfo should never be called in production mode. This is a bug in React.',
4281 );
4282 }
4283
4284 const existingRef = request.writtenDebugObjects.get(componentInfo);
4285 if (existingRef !== undefined) {
4286 // Already written
4287 return existingRef;
4288 }
4289
4290 if (componentInfo.owner != null) {
4291 // Ensure the owner is already outlined.
4292 outlineComponentInfo(request, componentInfo.owner);
4293 }
4294
4295 // Limit the number of objects we write to prevent emitting giant props objects.
4296 let objectLimit = 10;
4297 if (componentInfo.stack != null) {
4298 // Ensure we have enough object limit to encode the stack trace.
4299 objectLimit += componentInfo.stack.length;
4300 }
4301
4302 // We use the console encoding so that we can dedupe objects but don't necessarily
4303 // use the full serialization that requires a task.
4304 const counter = {objectLimit};
4305
4306 // We can't serialize the ConsoleTask/Error objects so we need to omit them before serializing.
4307 const componentDebugInfo: Omit<
4308 ReactComponentInfo,
4309 'debugTask' | 'debugStack',
4310 > = {
4311 name: componentInfo.name,
4312 key: componentInfo.key,
4313 };
4314 if (componentInfo.env != null) {
4315 // $FlowFixMe[cannot-write]
4316 componentDebugInfo.env = componentInfo.env;
4317 }
4318 if (componentInfo.owner != null) {
4319 // $FlowFixMe[cannot-write]
4320 componentDebugInfo.owner = componentInfo.owner;
4321 }
4322 if (componentInfo.stack == null && componentInfo.debugStack != null) {
4323 // If we have a debugStack but no parsed stack we should parse it.
4324 // $FlowFixMe[cannot-write]
4325 componentDebugInfo.stack = filterStackTrace(
4326 request,
4327 parseStackTrace(componentInfo.debugStack, 1),
4328 );
4329 } else if (componentInfo.stack != null) {

Callers 9

renderFunctionComponentFunction · 0.85
renderClientElementFunction · 0.85
visitAsyncNodeFunction · 0.85
emitErrorChunkFunction · 0.85
outlineIOInfoFunction · 0.85
serializeIONodeFunction · 0.85
renderDebugModelFunction · 0.85
emitConsoleChunkFunction · 0.85
forwardDebugInfoFunction · 0.85

Calls 6

filterStackTraceFunction · 0.85
outlineDebugModelFunction · 0.85
setMethod · 0.80
parseStackTraceFunction · 0.70
serializeByValueIDFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected