I am new in React.js. I have below code, where the variable modalOpen
value is not changing.
constructor(props) {
super(props);
this.state = {
modalOpen: false,
};
this.view = this.view.bind(this);
}
view() {
this.setState({ modalOpen: true });
alert(this.state.modalOpen)
}
render() {
return (
<button className="mini ui button" onClick={this.view}>
<i className="user icon"></i>
View
</button>
)
}
How can I change the value ?