question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:

  1. 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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
mimshinscommented, Aug 13, 2020

Any progress on this issue?

3reactions
oliviertassinaricommented, Nov 12, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found