In my reactjs app I have a button that is disabled/enabled based on a state value:
<button disabled={this.state.modelvalue === 0 ? true : false} onClick={this.showMessage}>Select</button>
The modelvalue state is set by changing the select value:
<div className="row">
<div className="col-md-6">
<select name="" id="" value={this.state.modelvalue} onChange={this.handleChangeModel}>
<option value ="0">plse select value</option>
<option value ="1">One</option>
</select>
</div>
</div>
handleChangeModel(event) {
this.setState({modelvalue: event.target.value});
}
The handleChangeModel sets the state.modelvalue but for some reason when you change from 'one' back to 'plse select value' the button does not get disabled? Even though the state.modelvalue is 0 again?