-
-
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
More clarification when not to use react/react-in-jsx-scope (Next.js) #2440
Comments
It's worth a mention, but there's still value in not doing what Next.js does, and explicitly importing React in every file. |
That would be worth adding then. I'd like to know why, too... |
Because explicit > implicit, and relying on implicitly added globals is magic that makes it harder for new users to understand what's going on. |
@ljharb While I totally agree explicit > implicit, babel v8 will automatically import react, it brings benefit to automatically decide whether to import from I think it is a new angle to the issue. Should we reconsider to update documentation and also recommended config? |
That's still an RFC, and very much not a certainty (that post isn't from babel or react, ftr), and either way that's a long way off. At the moment, you should always have |
I guess the Babel 8 + React 17 change to automatically import React with the new JSX transform is getting closer to reality: Aside from Next.js, now Gatsby has support for this: In case this keeps going this way, it may make sense at some point in the next year or two to re-evaluate this rule. |
Looks like it's getting more real (besides Gatsby and Next.js, CRA v4 will support it, and the change will also be backported to React 0.14.x, 15.x, and 16.x): https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html @ljharb what are your thoughts on re-opening this issue? |
If you're using react 17, you'd simply disable this rule. As soon as React 17 is fully released, we'll update the docs page. |
I think the doc page for react/react-in-jsx-scope should better detail when this rule is not to be used. For example, Next.js imports React when compiling so you don't need to do it yourself, but it doesn't technically "set
React
as a global variable" like described under "When Not To Use It".The text was updated successfully, but these errors were encountered: