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 all demos of the docs to include "use client" when needed #38966

Open
Tracked by #34905
oliviertassinari opened this issue Sep 13, 2023 · 3 comments
Open
Tracked by #34905
Assignees
Labels
docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 13, 2023

Summary 💡

The nominal user experience for a developer starting with Material UI is the following:

  1. Start with an example https://mui.com/material-ui/getting-started/example-projects/
Screenshot 2023-09-16 at 17 46 59

https://analytics.google.com/analytics/web/#/analysis/p353089763/edit/IBVRQAiCT2mrgZwzpg9fFQ

  1. 28% are going with Next.js App router
  2. Install it, use the first template.
  3. Go to https://mui.com/material-ui/react-select/#basic-select copy the first demo
Screenshot 2023-09-14 at 01 20 45

So I think we should update all the demos in the docs to have "use client" where needed.

Examples 🌈

Screenshot 2023-09-14 at 01 24 44 Screenshot 2023-09-14 at 01 24 48

Motivation 🔦

Better DX

Benchmarks

SCR-20240402-tgeh
@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 Sep 13, 2023
@mnajdova mnajdova assigned mj12albert and unassigned mnajdova Sep 16, 2023
@mnajdova
Copy link
Member

This makes sense to me. @mj12albert we should likely extend the rsc:build cmd to apply the changes on the docs demos too.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Sep 16, 2023

I don't know about rsc:build. We already have docs:typescript:formatted that goes over the demos. I think it could make more sense to rename this script so that we can only have one script & one pass on each demo file, it could run faster. In the future, I could very well see automatic style engine change happening in that script as well.

rsc:build the name of this script is strange. This is not a build phase script. Maybe rsc:append? It would make a lot more sense to me.

Now, I do think that both scripts should share the same logic, even if they don't handle the same files.

rsc:build blindly applying "use client" is OK as a v0 but not as a v1, we need to support full server components as well, see 🔽

Otherwise, the idea of automating makes a ton of sense. I think it should at least add "use client" if there are non-compatible hooks used. I'm not sure we will be able to automatically detect non-serializable props, so we might not be able to remove "use client" automatically.

@oliviertassinari oliviertassinari added enhancement This is not a bug, nor a new feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 16, 2023
@oliviertassinari
Copy link
Member Author

To get a better sense of the relevance of this issue, I did a quick analysis on the downloads https://www.notion.so/mui-org/Monthly-meeting-2023-09-12-b55ca5b7944a4658822de0356a596f6c?pvs=4#b4af5477544d47d4bea7239aadacca70. I feel that it makes sense to add the "use client" at the expense of those who don't need them as it doesn't feel we focus enough on Next.js integration.

If we really have developers using Vite, CRA who push back, I think we could create a setting to automatically remove them:

Screenshot 2023-09-16 at 18 16 14

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 enhancement This is not a bug, nor a new feature
Projects
None yet
Development

No branches or pull requests

3 participants