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

Function serializeDebugModel

packages/react-server/src/ReactFlightServer.js:5059–5101  ·  view source on GitHub ↗
(
  request: Request,
  objectLimit: number,
  model: mixed,
)

Source from the content-addressed store, hash-verified

5057}
5058
5059function serializeDebugModel(
5060 request: Request,
5061 objectLimit: number,
5062 model: mixed,
5063): string {
5064 const counter = {objectLimit: objectLimit};
5065
5066 function replacer(
5067 this:
5068 | {+[key: string | number]: ReactClientValue}
5069 | $ReadOnlyArray<ReactClientValue>,
5070 parentPropertyName: string,
5071 value: ReactClientValue,
5072 ): ReactJSONValue {
5073 try {
5074 return renderDebugModel(
5075 request,
5076 counter,
5077 this,
5078 parentPropertyName,
5079 value,
5080 );
5081 } catch (x) {
5082 return (
5083 'Unknown Value: React could not send it from the server.\n' + x.message
5084 );
5085 }
5086 }
5087
5088 const prevNoOutline = debugNoOutline;
5089 debugNoOutline = model;
5090 try {
5091 // $FlowFixMe[incompatible-cast] stringify can return null
5092 return (stringify(model, replacer): string);
5093 } catch (x) {
5094 // $FlowFixMe[incompatible-cast] stringify can return null
5095 return (stringify(
5096 'Unknown Value: React could not send it from the server.\n' + x.message,
5097 ): string);
5098 } finally {
5099 debugNoOutline = prevNoOutline;
5100 }
5101}
5102
5103function emitOutlinedDebugModelChunk(
5104 request: Request,

Callers 3

emitDebugChunkFunction · 0.85
emitIOInfoChunkFunction · 0.85
emitConsoleChunkFunction · 0.85

Calls 1

stringifyFunction · 0.85

Tested by

no test coverage detected