You are on page 1of 1

JS

class App extends React.Component {


state = {
btn_color:'button-red'
};

onClick = (event) => {


this.setState({
btn_color:'button-grey'
})
}
render() {
return (
<div>
<button
onClick={this.onClick}
className={this.state.btn_color}
>
CLICK ME!
</button>
</div>
)
}
}

ReactDOM.render(
<App />,
document.querySelector('#root')
)

HTML
<div id='root' />

CSS

.button-red {
background-color: red;
color: white;
}
.button-grey{
background-color: grey ;
color:white;
}

You might also like