Suppose I have a state like below:
this.state = {
modal: ""
};
Then I have a button like below:
<button
type="button"
className="btn btn-primary"
onClick={this.createUser}
data-dismiss={this.state.modal}
> Save
</button>
The create User is like below:
createUser = () => {
this.setState({
modal: "modal"
});
};
So when I click the button, I want to close my bootstrap modal defined in the format of data-dismiss button, because I assigned it as modal in createUser.
But its only working in he 2nd click of save button. Why?
Also, how can I change to one click itsself ?