I would like to put the color of the background, according to a variable.
The code is:
return <div className="navbar" style={{ background: dataColor }}></div>;
This code only works for me when the assignment to the variable is like this:
const dataColor = "#120000";
And not like this:
const dataColor2 = props.children;
(props.children comes from somewhere else, and its value is correct. I checked it).
What is the problem?
Thank You!
CodePudding user response:
I would say the value is set to late. Try to use an await.
CodePudding user response:
return <div className="navbar" style={{ background: dataColor }}></div>;
const dataColor2 = this.props.children;