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>