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

Rule to forbid component dot notation? #3860

Open
FezVrasta opened this issue Dec 4, 2024 · 5 comments
Open

Rule to forbid component dot notation? #3860

FezVrasta opened this issue Dec 4, 2024 · 5 comments

Comments

@FezVrasta
Copy link

Hi, with server components the component dot notation (Group.Foo) is not supported, it would be useful to have an eslint rule that forbids its usage to avoid issues like the one described here:

vercel/next.js#51593 (comment)

The React error is:

Cannot access .Foo on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
@ljharb
Copy link
Member

ljharb commented Dec 4, 2024

This is a confusing requirement and seems very unidiomatic for JS. Is it coming from next.js or from actual React RSC? If the latter, can you find a react issue where it's discussed?

@FezVrasta
Copy link
Author

From what I see it's coming from React itself. I'll dig further and get back to you

@FezVrasta
Copy link
Author

FezVrasta commented Dec 5, 2024

@ljharb
Copy link
Member

ljharb commented Dec 5, 2024

Then I think it's incumbent on the React team to provide a canonical way to statically determine if a component is server or client. This can be a library (best), or an algorithm or heuristics to use (but in this case, they'd basically never be able to change them).

@FezVrasta
Copy link
Author

To be fair I would be okay with a rule that forbids them all the time. I wouldn't want to mess with refactors in case a component has to be moved from server to client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants