Answer the question
In order to leave comments, you need to log in
How to change styles based on state in React?
I use styled-components and react, when you click on the button, you need to change its styles, here is an example https://codesandbox.io/s/ry52xp992m.
Answer the question
In order to leave comments, you need to log in
render() {
const { isSelected } = this.state;
const content = isSelected ? '1' : '0';
return (
<App>
<Button
onClick={this.handleClick}
isSelected={isSelected}
>
Button
</Button>
<p>{content}</p>
</App>
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question