-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[system] Remove createUseThemeProps, RtlProvider, DefaultPropsProvider, useDefaultProps API #43443
Comments
Off-topic (style theme nesting isn't something I was thinking of covering in this issue) As far as I understand, nested theming for styles should be supported by using CSS variables. It's the
We should try to have no inline style in the framework for strict CSP policies. If we can have this in a class name, this would be better. |
I don't see a picture of it. Is server-side theme is the one you define in the config (e.g. next.config.js)?
Then, how do you support dynamic runtime styles? Inline style seems to be the only way to connect JS with CSS statically.
|
@siriwatknp Property assignment: #19938
For Emotion RSC and runtime theme dependencies, you define it once in a RSC and once in a React Client Component. Actually because of this: https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#supported-pattern-passing-server-components-to-client-components-as-props we can likely have a single component that does both client and server context assignment under the hood. For zero-runtime RSC, yeah, you also need to define it in the plugin that does the transpilation. |
They use the React.cache for the server context: https://yak.js.org/how-does-it-work |
I think the same applies to the new
Practical example: https://github.com/jantimon/next-yak/blob/main/packages/next-yak/runtime/context/index.server.tsx#L14 |
I think we can work on this until |
From what I see in the example you posted, it's still using a client component with React context. And as @siriwatknp said, we can't experiment or try cache API till it's available through a stable release. |
In their case, they use the entry point to split: https://github.com/jantimon/next-yak/blob/47d2ed61429335cb87caf68a2776aa582bc7e21c/packages/next-yak/package.json#L28 (I was using a try catch in my POC)
Likely something to test with other bundlers: https://twitter.com/leeerob/status/1772651496544317804, my understanding is that RSC is experimental as the cache API. |
True. But their server entry point then imports a client file, ie, YakThemeProvider |
I'm extending the scope of this issue to Now, the only concern for me is the support of theme nesting on RSC and client-side components. This looks more important to support theme nesting than the default prop on RSC. The React.cache() or window.__theme solution doesn't support theme nesting. As I understand it, today, Pigment CSS doesn't support it either. So I would only explore how to support theme nesting before removing all of these APIs (createUseThemeProps, RtlProvider, and DefaultPropsProvider). |
A quick POC: https://github.com/oliviertassinari/test-theme it seems to work, so it seems that we can move forward with removing all of those APIs:
as well as fixing emotion-js/emotion#2978. |
Summary
From #40648 (comment)
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: mui/mui-x#12180).Now, I don't think this change is needed, we can have context (maybe with nesting support but not sure) emotion-js/emotion#2978 (comment).
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:
This way, we get:
Opportunity moved to #43443
Search keywords:
Search keywords:
The text was updated successfully, but these errors were encountered: