-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[styles] Dynamic makeStyles unexpected behavior #15511
Comments
cc @kof |
Any news on this? |
Same here is called too many times unnecessary |
Encountered this problem as well. I noticed that this problem only occurs when using a nested selector. So adding a separate class to the element the nested selector points at and adding the dynamic styling to that class should solve the problem. In this code sandbox I debugged the problem: Note: In my browser (FireFox) I had to close and open the inspector to see the affect, thus make sure you follow the debug instructions in the demo. ConclusionThis doesn't work:
This does work:
|
Is there any update on this issue? Still getting more than one class when using props for adaptive styling. |
Also interested in item 6 – I'd imagine it can be fixed with a small change like schnerd@21f98bd. |
These issues should have been solved in v5 thanks to #22342 and the new |
So, what's the work around on v4? |
@oliviertassinari A workaround for v4 would be really awesome. We have huge application, which is using material-ui. |
@ffjanhoeck I would recommend trying react-jss out. The migration should be easy and they have a better handling of this problem. Also note that you don't need to migrate all the makeStyles and withStyles in v5, the module is still here. |
@oliviertassinari Is the Or do you mean by trying out react-jss, that I should directly use react-jss, without the makeStyles from material-ui ? |
@ffjanhoeck Material-UI v4 uses jss, not react-jss. My suggestion is to use react-jss |
An update, we have now made enough progress with the new
This was made possible by the awesome work of @mnajdova. |
Hi @oliviertassinari I couldn't find anything about it in the docs. Thanks. |
@maticrivo this worked for me. add to createStyles in makeStyles |
I have found some issues using
makeStyles
with dynamic styles (arrow functions) and i'm going to list them here since i think those may be related, and i feel that is unnecessary to create one issue per each of these points.This issues are shown in this codesandbox MCVE https://codesandbox.io/s/lrwvw5lx6q.
This behavior may be the intended to allow the reference of a static class from a dynamic class but i don't think is working, at least not completely.
$
) a static class (not using arrow function) from a dynamic class (using arrow).makeStyles
and i see that it does not depend on props, everytimeuseStyles
is called and no matter if the props are the exacly the same the stylesheet is updated. Any reason for this?Because when you call
useStyles(props)
with the same props or even using something like this:Doesn't seem necessary to update the stylesheets.
Expected Behavior
makeStyles-animate-10
Current Behavior
makeStyles-animate-4 makeStyles-animate-10
index.js:26 Warning: [JSS] Could not find the referenced rule simple in makeStyles.
index.js:26 Warning: [JSS] Referenced keyframes rule "rotate1" is not defined.
Steps to Reproduce
simple
fromsimple: {}
tosimple: () => ({})
the titleHello CodeSandbox
will have the expected green color.h2
containingYou clicked X times!
or checking the rules in the sandboxdocument.styleSheets
there will be multiple rule definitions repeated.rotate2
that is inside an arrow function is generated with empty body. The animation is not being applied.rotate1
is generated correctly but it is not referenced. The animation is not being applied.Your Environment
Not sure if all this points are really issues or some of them are not allowed and its behavior is undefined.
The text was updated successfully, but these errors were encountered: