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

[docs] react in jsx scope #42169

Open
oliviertassinari opened this issue May 9, 2024 · 2 comments
Open

[docs] react in jsx scope #42169

oliviertassinari opened this issue May 9, 2024 · 2 comments
Assignees
Labels
docs Improvements or additions to the documentation dx Related to developers' experience status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented May 9, 2024

Summary

See https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports for context. Most of the demos in the docs could be written without the import of React.

This is also reflected in https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md.

Examples

Motivation

In the past, we didn't do the change because there was too many React users <17.0.0. But this seems to mostly OK now:

SCR-20240509-czwr

https://tools-public.mui.com/prod/pages/npmVersion?package=react

Search keywords: optional import react

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 9, 2024
@brijeshb42
Copy link
Contributor

Agreed. We can atleast start with our own docs, update the eslint rules, and then update the examples.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented May 11, 2024

Vite (latest version) warn when starting a new project and copying and pasting our demos in the docs:
SCR-20240511-oeqy
So there is a DX cost in having those react imports.

Next.js (latest version) doesn't say anything, it's happy with having import * as React from 'react' or not having it.

@oliviertassinari oliviertassinari added the dx Related to developers' experience label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation dx Related to developers' experience status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants