I'm working with older versions of material-ui with no possibility to upgrade.
I am trying to change the background of the Paper component based on a few combinations of the props. I don't think it's complicated to require use of the makeStyles HOC. Is this possible?
I think the problem is this line: classes={{ root: correctBackgroundColor.root }}
but the documentation on the https://v0.material-ui.com/#/components/paper unhelpfully says "Other properties (not documented) are applied to the root element."
import React from "react";
const correctBackgroundColor = {
root: {
width: 30,
height: 30,
border: "1px solid lightgrey",
backgroundColor: props => {
if (props.ledIsOn === true && props.ledColorType === "Green") {
return "#00FF00";
}
if (props.ledIsOn === true && props.ledColorType === "Orange") {
return "#FFA500";
}
}
}
};
class ColorChange extends React.Component {
render() {
const { classes } = this.props;
let textToRender = (
<Paper
id={this.props.id}
classes={{ root: correctBackgroundColor.root }}
/>
);
return (
<div>
<Typography variant="p" className={classes.typography_root}>
{this.props.textLabel}
</Typography>
{textToRender}
</div>
);
}
}
export default withStyles(styles)(ColorChange);
there is a sandbox at : https://codesandbox.io/s/adoring-bell-oyzsn TIA!