@samitouri / QOS-React-2 / commits / c8510227c1

Treat displayName as undefined (#26148)

When we have a key we read displayName eagerly for future warnings. In general, React should be inspecting if something is a client reference before dotting into it. However, we use displayName a lot and it kind of has defined meaning for debugging everywhere it's used so seems fine to treat this as undefined.

Sebastian Markbåge committed Feb 10, 2023 at 11:23 UTC c8510227c1b9c4049979b81e998ec40545e2ce9b
2 files changed +9
packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js
+2
@@ -48,6 +48,8 @@ module.exports = function register() {
48 return target.filepath;
49 case 'name':
50 return target.name;
51 + case 'displayName':
52 + return undefined;
53 case 'async':
54 return target.async;
55 // We need to special case this because createElement reads it if we pass this
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js
+7
@@ -466,6 +466,13 @@ describe('ReactFlightDOM', () => {
466 );
467 });
468
469 + it('does not throw when React inspects any deep props', () => {
470 + const ClientModule = clientExports({
471 + Component: function () {},
472 + });
473 + <ClientModule.Component key="this adds instrumentation" />;
474 + });
475 +
476 it('throws when accessing a Context.Provider below the client exports', () => {
477 const Context = React.createContext();
478 const ClientModule = clientExports({