dillon1000/react

Commit

[Flight] Support classes in renderDebugModel (#33590)

This adds better support for serializing class instances as Debug
values.

It adds a new marker on the object `{ "": "$P...", ... }` which
indicates which constructor's prototype to use for this object's
prototype. It doesn't encode arbitrary prototypes and it doesn't encode
any of the properties on the prototype. It might get some of the
properties from the prototype by virtue of `toString` on a `class`
constructor will include the whole class's body.

This will ensure that the instance gets the right name in logs.

Additionally, this now also invokes getters if they're enumerable on the
prototype. This lets us reify values that can only be read from native
classes.

---------

Co-authored-by: Hendrik Liebau <[email protected]>
Browse files
Changed paths4 files
First-parent comparison
M packages/react-client/src/ReactFlightClient.js ModifiedM packages/react-client/src/__tests__/ReactFlight-test.js ModifiedM packages/react-server/src/ReactFlightServer.js ModifiedM packages/shared/ReactSerializationErrors.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…