I am currently working on a react component that has a specific style defined as shown below:
const StyledInnerItem = withStyles((theme) => ({
bgColor: {
backgroundColor: (props) => {
console.log('styledInnerItem color: ', props.color);
return 'red';
}
}
}))(InnerItem);
My intention is to set the background color of the component based on the props.color value. However, I am facing an issue where it doesn't even return the temporary red color that I have set as the fallback option. When I check the logged props, it shows the correct color from the first render, and it gets added to the HTML file. However, the styles are only applied when I click on the component, resulting in the correct colors being displayed.
Everything works perfectly fine when the background color is not defined as a function. I need to achieve the same functionality by reading the color value directly from the props.