-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: react/prefer-read-only-props
doesn't work with async components
#3653
Comments
What are async components? |
In this RFC (dec. 2020) React introduced server components. Although they are still experimental and not available in stable react app, they are the new default in Nextjs. This components returns a Promise and they let you fetch data in asynchronous components that run on the server or even during the build. Instead of relying on You can find some documentation with better explanations here: https://react.dev/learn/start-a-new-react-project#bleeding-edge-react-frameworks Typescript handles them now I think since this PR (nov. 2022) (microsoft/TypeScript#51328) |
Since they're still experimental, we don't support them yet, and it sounds like a pretty bad decision for nextjs to default to using them. Once they're stable, I'd be happy to review a PR that adds support for them. |
I just want to clarify the "experimental" wording, after doing some research here is what I found from this article from May, from the react team:
|
I think that's harmful encouragement, and frameworks that follow it are similarly not doing their users a service. If you think you can make a PR that would cover this, though, I'll review it. |
Made a quick PR feel free to suggest any changes, tests are running correctly. |
Just want to point out, I have a lot of respect for you and I understand your point of view but… I didn't made those decisions… However, as many others, I use nextjs daily in my 9 to 5 and wanted to help what I think is a bug in the rules. |
Is there an existing issue for this?
Description Overview
The code below does not trigger the rule. But if I remove the
async
keyword and thegetData()
the rule now errors correctly. I'm using nextjs app dir with server components.Expected Behavior
Shouldn't the rule errors whether the component is async or not? Maybe I misunderstood something in the docs.
eslint-plugin-react version
v7.33.2
eslint version
v8.53.0
node version
v18.x
The text was updated successfully, but these errors were encountered: