Skip to content

Commit

Permalink
Treat displayName as undefined (#26148)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage committed Feb 10, 2023
1 parent 55542bc commit c851022
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ describe('ReactFlightDOM', () => {
);
});

it('does not throw when React inspects any deep props', () => {
const ClientModule = clientExports({
Component: function () {},
});
<ClientModule.Component key="this adds instrumentation" />;
});

it('throws when accessing a Context.Provider below the client exports', () => {
const Context = React.createContext();
const ClientModule = clientExports({
Expand Down

0 comments on commit c851022

Please sign in to comment.