I try to build a message page for help and support at my web, I use a <select>
and <option>
. But when i change a option value from <select>
, the value return to default value first and then change to next value
This is my select
<select
id="selectMessageSubject"
defaultValue={this.state.subject}
onChange={this.handleSubjectChange}
className="form-control"
>
<option value="PRAY">{ T.translate('message.pray') }</option>
<option value="INFO">{ T.translate('message.info') }</option>
<option value="CARE">{ T.translate('message.treat') }</option>
</select>
and this is my function to handle when the value is change
handleSubjectChange(evt){
this.setState({ subject: evt.target.value });
console.log(this.state.subject);
}
and this is my default value for <select>
constructor(props){
super(props);
this.state={
subject: 'PRAY'
}
this.handleSubjectChange = this.handleSubjectChange.bind(this);