[styles] withStyles - makeStyles - Can't use props (function) in nested styles
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Whenever I try to use function as backgroundColor: props => props.color
for nested styles in makeStyles
or withStyles
the style does not work.
Expected Behavior 🤔
It should be possible to use props (function approach) in makeStyles
, withStyles
for nested styles.
Steps to Reproduce 🕹
Go to: https://codesandbox.io/s/cant-use-props-in-nested-style-pz885
Steps:
- Try to change backgroundColor of track using function (line 20, demo.js)
Context 🔦
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.9.8 |
React | v16.13.1 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
[styles] withStyles - makeStyles - Can't use props (function) in ...
It should be possible to use props (function approach) in makeStyles , withStyles for nested styles. Steps to Reproduce. Go to: https:// ...
Read more >JSS nested styles container - reactjs - Stack Overflow
Btw. I want to provide a mechanism to change the styles of my components from outer application so that's why I can't use...
Read more >Advanced (LEGACY) - MUI System
The wrapped component accepts a classes prop, it simply merges the class names provided with the style sheet. const Nested = withStyles({ root:...
Read more >Styling with React's Material-UI v4 – Part 1 - ireadyoulearn.
Dynamic styling by passing data to the makeStyles function. Styling nested child elements – with the parent selector (&), and the reference ...
Read more >Style - Motif
Style overrides should be used in accordance with UX/Design; use overrides ... function Nested(props) { const classes = useStyles(); return ( <button ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any progress on this issue?
An update, this issue is being resolved in v5 thanks to #22342 and the new
@material-ui/styled-engine
package. The$ruleName
API is no longer available on the styled-components API. Instead, developers can leverage the global class names, which is a step closer to relying on CSS and removes the need to learn a new syntax. This one has caused a lot of friction for new comers.