-
-
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
[Box][styled] Cache makeStyles() per JSON of props for style functions #16858
Conversation
d191188
to
e3e4c4d
Compare
@material-ui/core: parsed: +0.29% , gzip: +0.39% Details of bundle changes.Comparing: 78db8a0...6a07098
|
Please include benchmark results using the production build once this is ready for review. |
e3e4c4d
to
b0c2515
Compare
I decided to implement cache on |
b0c2515
to
2e0da02
Compare
oops, something wrong. |
2e0da02
to
1610b10
Compare
if ( | ||
name && | ||
name.indexOf('Mui') === 0 && | ||
!styleSheet.options.muiDynamic && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was important to use different class name for every Box instance (otherwise class name of all elements will be "MuiBox-root").
0ce6450
to
75d179d
Compare
75d179d
to
6a07098
Compare
Sorry for bothering with force-pushes. Finally fixed issues! |
@ypresto Thank you for working on the problem! It's important. I will soon have a look at it :) |
oliviertassinari this its important, when useStyles its called with props its called two times per render, so the first render don't match with the server any time, and its completely inefficient called more times the same thing. but more important never match with server classes when props its present because the counter its called two times on the client. |
@oliviertassinari what's the status with it ? It's going to be merged some day ? |
@ypresto As we are moving to a unstyled core and adapters for styled-components/emotion/jss, it's probably not worth pushing further. Thanks for the exploration! It could be interesting to move the concern to jss. |
Fixes #16704
Make styled() use filterProps value to generate cache key.
You can use
_useStylesCache: null
option to disable this behavior.It's still 2x slower than useStyles(), but 5x faster than original implementation..! (This benchmark creates 100 Boxes at once)
Limitations:
m={2}
) and non-alias (margin={2}
) props will create different cache.link: true
and updating existing style ifrefs === 1
can solve this.