Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete name property from client reference in Flight Node Register #26322

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ module.exports = function register() {

const deepProxyHandlers = {
get: function (target: Function, name: string, receiver: Proxy<Function>) {
const [, targetName] = target.$$id.split('#');

switch (name) {
// These names are read by the Flight runtime if you end up using the exports object.
case '$$typeof':
Expand All @@ -48,7 +50,7 @@ module.exports = function register() {
case '$$async':
return target.$$async;
case 'name':
return target.name;
return targetName;
case 'displayName':
return undefined;
// We need to special case this because createElement reads it if we pass this
Expand All @@ -69,7 +71,7 @@ module.exports = function register() {
);
}
// eslint-disable-next-line react-internal/safe-string-coercion
const expression = String(target.name) + '.' + String(name);
const expression = String(targetName) + '.' + String(name);
throw new Error(
`Cannot access ${expression} on the server. ` +
'You cannot dot into a client module from a server component. ' +
Expand All @@ -95,8 +97,6 @@ module.exports = function register() {
return target.$$id;
case '$$async':
return target.$$async;
case 'name':
return target.name;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case was not covered by a unit test, but I think it's dead code and can not be reached.

// We need to special case this because createElement reads it if we pass this
// reference.
case 'defaultProps':
Expand Down Expand Up @@ -185,7 +185,6 @@ module.exports = function register() {
);
}: any),
{
name: {value: name},
Copy link
Contributor Author

@unstubbable unstubbable Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this was left in intentionally for convenience (i.e. reading it in deepProxyHandlers), feel free to just close the PR. But including the name here, but not in all the other branches, felt inconsistent and confusing to me.

$$typeof: {value: CLIENT_REFERENCE},
$$id: {value: target.$$id + '#' + name},
$$async: {value: target.$$async},
Expand Down