Answer the question
In order to leave comments, you need to log in
Why write code like this?
There is a code that changes classes (adds or removes):
https://jsfiddle.net/rjhzf0wk/
there is this line:
<div className={(this.state.opened) ? "mystyle" : ""}>Текст</div>
<div className="mystyle">{this.state.opened}Текст</div>
Answer the question
In order to leave comments, you need to log in
Because the first piece of code checks what value is stored in the state, and if true, sets the mystyle class. And your code creates a block with the mystyle class, and enters text into it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question