-
I would like to pass a prop to assign a background color to a table. Is it possible to do sth like this? for instance:
I have searched everywhere in the documentation for version 9 but nothing is mentioned |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @kboul, const useStyles = makeStyles({
tableRowBase: {
...
},
backgroundColor1: {
backgroundColor: 'oneColor'
},
backgroundColor2: {
backgroundColor: 'otherColor'
}
});
const MyComponent = (props) => {
const styles = useStyles();
const tableRowClassName = mergeClasses(styles.tableRowBase, props.someProp ? styles.backgroundColor1 : styles.backgroundColor2);
...
} I hope that helps! |
Beta Was this translation helpful? Give feedback.
Hi @kboul,
makeStyles
in version 9 can be optimized at build time, which makes doing something like the above not possible since we wouldn't know the runtime value ofsomeProp
beforehand. What you can do for those cases is something like the following:I hope that helps!