Skip to content

Commit c851022

Browse files
authored
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.
1 parent 55542bc commit c851022

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ module.exports = function register() {
4848
return target.filepath;
4949
case 'name':
5050
return target.name;
51+
case 'displayName':
52+
return undefined;
5153
case 'async':
5254
return target.async;
5355
// We need to special case this because createElement reads it if we pass this

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,13 @@ describe('ReactFlightDOM', () => {
466466
);
467467
});
468468

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+
469476
it('throws when accessing a Context.Provider below the client exports', () => {
470477
const Context = React.createContext();
471478
const ClientModule = clientExports({

0 commit comments

Comments
 (0)