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] Update Material UI code snippets for React 18 #32361

Merged
merged 13 commits into from
Apr 29, 2022

Conversation

samuelsycamore
Copy link
Member

@samuelsycamore samuelsycamore commented Apr 18, 2022

This PR updates all pages in the Material UI docs with code snippets that feature the deprecated way of rendering:

ReactDOM.render(<App />, document.querySelector('#app'));

EDIT: all instances have been removed (rather than being replaced).

@samuelsycamore samuelsycamore requested review from a team and oliviertassinari April 18, 2022 23:19
@samuelsycamore samuelsycamore added the docs Improvements or additions to the documentation label Apr 18, 2022
@mui-bot
Copy link

mui-bot commented Apr 18, 2022

Details of bundle changes

@material-ui/core: parsed: +Infinity% , gzip: +Infinity%
@material-ui/lab: parsed: +Infinity% , gzip: +Infinity%
@material-ui/styles: parsed: +Infinity% , gzip: +Infinity%
@material-ui/private-theming: parsed: +Infinity% , gzip: +Infinity%
@material-ui/system: parsed: +Infinity% , gzip: +Infinity%
@material-ui/unstyled: parsed: +Infinity% , gzip: +Infinity%
@material-ui/utils: parsed: +Infinity% , gzip: +Infinity%
@mui/material-next: parsed: +Infinity% , gzip: +Infinity%
@mui/joy: parsed: +Infinity% , gzip: +Infinity%

Generated by 🚫 dangerJS against 86ac27f

@siriwatknp
Copy link
Member

@samuelsycamore instead of changing to React.createRoot(...), what if we remove the line. I don't see that it is necessary to have the ReactDOM.render(<App />, document.querySelector('#app')); or React.createRoot(...) in our doc. It creates a dependency on the doc which we will have to change every time React introduce new APIs.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 19, 2022

what if we remove the line.

@siriwatknp For context, the idea of this line was to show that it's all that is needed, there is no provider and other some sort of configuration is needed (We used to require some configuration, I think in v0, developers were complaining about it).

@samuelsycamore
Copy link
Member Author

I appreciate the point made in the intro docs to say "this is everything you need," but it does feel mostly unnecessary otherwise. I would assume that any React dev who's digging around in our docs understands how React components work and doesn't need the rendering line pointed out to them. I'm cool with just removing it entirely.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 19, 2022

I would assume that any React dev who's digging around in our docs understands how React components work and doesn't need the rendering line pointed out to them

@samuelsycamore Agree. Now, this was not the purpose of showing this line of code. The purpose was to demonstrate that MuiThemeProvider or any other provider is not equired in v1 like it was in v0: https://v0.mui.com/#/get-started/usage (it was adding friction and leading to people opening annoying GitHub issues).

I think it's better to keep this line to be very clear, but if you think that it's better without, why not remove it.

@samuelsycamore
Copy link
Member Author

That makes sense. In that case, I'm in favor of removing it.

@@ -248,7 +248,7 @@ function App() {
return <StylesProvider jss={jss}>...</StylesProvider>;
}

ReactDOM.render(<App />, document.querySelector('#app'));
ReactDOM.createRoot(document.querySelector('#app')).render(<App />);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this page about @mui/styles? If so then we shouldn't use React 18 APIs since that package isn't compatible with React 18.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @eps1lon!

@michaldudak
Copy link
Member

I found one more occurrence of ReactDOM.render in the main readme. Would you mind updating it as well?

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 27, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 27, 2022
@samuelsycamore samuelsycamore requested a review from a team April 27, 2022 14:06
@samuelsycamore samuelsycamore merged commit 83d1681 into mui:master Apr 29, 2022
@samuelsycamore samuelsycamore deleted the react-18-usage-learn branch April 29, 2022 22:52
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 12, 2022

We removed the line but we didn't remove the react-dom import:

Screenshot 2022-06-12 at 15 34 11

I'm fixing this in #33122

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants