You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The scope of this "RFC" is to discuss about the possibility to use CSS Custom Properties for dynamic styles.
Switching to use CSS Custom Properties might allow us to explore static extraction in the future.
This mode would be optional and disabled by default as many might still need to support IE, it will also be a breaking change because we would need to allow interpolations only for CSS values:
Interpolations, and therefore the entire template literal containing the CSS, are flagged as dynamic when they have an expression that cannot be evaluated at build time.
When this is the case we rewrite the styles as follow:
We also hash the string above to have a base ID, say 123. Then we rewrite the className attribute of every JSX element to include a fn that generates the proper ID at runtime based on props:
This is just an idea I had a while ago, likely I might not have time to implement it soon but I wanted to put it out there in case anybody is interested
The scope of this "RFC" is to discuss about the possibility to use CSS Custom Properties for dynamic styles.
Switching to use CSS Custom Properties might allow us to explore static extraction in the future.
This mode would be optional and disabled by default as many might still need to support IE, it will also be a breaking change because we would need to allow interpolations only for CSS values:
How dynamic styles work right now
Interpolations, and therefore the entire template literal containing the CSS, are flagged as dynamic when they have an expression that cannot be evaluated at build time.
When this is the case we rewrite the styles as follow:
We also hash the string above to have a base ID, say
123
. Then we rewrite theclassName
attribute of every JSX element to include a fn that generates the proper ID at runtime based on props:JSXStyle.dynamic
's signature is:It takes an
Array<JSXStyleInfo>
because there could be multiple style tags per component.At runtime then it basically maps
JSXStyleInfo
to create an hash from JSXStyleInfo, and then flattens the result to finally return classnamesInternally then
JSXStyle
does the same and replaces__jsx-style-dynamic-selector
withjsx-123abc
.Proposal
I think that we could rework this part to instead use custom properties:
We won't use any
__jsx-style-dynamic-selector
but rather use theBaseID
to generate the scoped classjsx-123
.Interpolations would be replaced with custom properties:
and the root JSXElement would set custom properties using
JSXStyle.dynamic
:The text was updated successfully, but these errors were encountered: