mui / mui/material-ui

[system] Remove createUseThemeProps, RtlProvider, DefaultPropsProvider, useDefaultProps API

Open
#43,443 12 comments 0 reactions 1 assignee View on GitHub

@brijeshb42 is already working on this.

Since Feb 26, 2024.

priority: important scope: system
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Summary

From https://github.com/mui/material-ui/pull/40648#issuecomment-1961591574

This PR aims to remove the usage of React context to make some components RSC compatible while having backward compatible with emotion.

What's the use case to have RSC compatible components? We use the Badge in the PR, but I guess it's not the objective (I don't see why a developer would want this with his component, there would be no state change animations, the onClick listener wouldn't works, etc.), but I guess the Badge is meant as a supplement for layout components. For instance, it makes a lot of sense to me with a <Container> with a different default layout mode propagated with the context or for a static content: https://github.com/mui/mui-x/issues/12180).

Now, I don't think this change is needed, we can have context (maybe with nesting support but not sure) https://github.com/emotion-js/emotion/issues/2978#issuecomment-1935131675.

Trade-off

But them, how can we support theme nesting? I don't see this mentioned, but I think it matters. For example, how is the documentation of Material UI supposed to be able to show components in their default form while the docs has a MUI branded theme?

At first sight, I would recommend:

  • We revert this PR.
  • We introduce a server side theme, to live in the server bundle, alongside the a client bundle theme. We need this anyway to get RSC support with Emotion.
  • We update the theme provider and theme customer to support both theme locations.

This way, we get:

  • No theme propagation feature regression on the client bundle, theme nesting continues to work. On the server bundle, the theme nesting mighty not work, it depends on how React calls the cache API, but I wouldn't expect it to be achievable. Maybe one-day if React introduce a true context RSC API.
  • The foundations for Emotion with RSC.

Opportunity moved to https://github.com/mui/material-ui/issues/43443

Search keywords:

Search keywords:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.