From 5d7cf6ee7c5594a98877c49a76254dd9ab05b785 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Fri, 10 Feb 2023 10:51:44 -0500 Subject: [PATCH] Treat displayName as undefined 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. --- .../src/ReactFlightWebpackNodeRegister.js | 2 ++ .../src/__tests__/ReactFlightDOM-test.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js index 7baab1c44c6ef..14b841c4b9cd4 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js @@ -48,6 +48,8 @@ module.exports = function register() { return target.filepath; case 'name': return target.name; + case 'displayName': + return undefined; case 'async': return target.async; // We need to special case this because createElement reads it if we pass this diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js index 89868fe82d055..54ae52f90554a 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js @@ -466,6 +466,13 @@ describe('ReactFlightDOM', () => { ); }); + it('does not throw when React inspects any deep props', () => { + const ClientModule = clientExports({ + Component: function () {}, + }); + ; + }); + it('throws when accessing a Context.Provider below the client exports', () => { const Context = React.createContext(); const ClientModule = clientExports({