mui / material-ui

Material UI: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
https://mui.com/material-ui/
MIT License
92.45k stars 31.85k forks source link

[docs] react in jsx scope #42169

Open oliviertassinari opened 1 month ago

oliviertassinari commented 1 month ago

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

brijeshb42 commented 1 month ago

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

oliviertassinari commented 1 month ago

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.