I need to know how to target 'element' when root is selected
This is makeStyles:
const useStyles = makeStyles(theme => ({
root:{
'&.selected': {
}
},
element: {
}
})
This is jsx
<div className={`${classes.root} ${elementSelected ? 'selected : ''}`}>
<div className={classes.element}>
</div>
</div>
You can use https://www.npmjs.com/package/classnames to achieve this.
const useStyles = makeStyles(theme => ({
root:{
'&.selected $element': {
}
}
})
And your JSX
import classNames from 'classnames';
...
<div className={classNames(classes.root, elementSelected ? 'selected : '')}>
<div className={classes.element}>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With