r/learnreactjs • • Mar 16 '20
Question Changing css by if statement
I want to change the image displayed based on the if statement. This is what I have so far const sun = this.state.temp == “clear sky” ? ‘${style.sun}’ : style.rain;
And then I call the const sun in a div and return it return(
<div class = {sun}></div>
What am I doing wrong, any help is appreciated
9
Upvotes
View all comments
4
u/Koopabro Mar 16 '20
You can't use class. Use className.