I've been struggling for the past few hours trying to get a simple dropdown change event to work, using ReactJS and Semantic UI. From my understanding, the onChange property of the element is supposed to fire the event handler it is bound to when a different option is selected. Here is my code:
var DictionarySelector = React.createClass({
getInitialState: function() {
return {value: ""}
},
handleChange: function(e) {
this.setState({value: e.target.value});
console.log('Dropdown changed');
return;
},
render: function() {
return (
<div className="ui form" style={{marginTop:'55px'}}>
<div className="field">
<select className="ui dropdown" onChange={this.handleChange} value={this.state.value}>
<option value="">Select Dictionary</option>
<option value="1">Dictionary 1</option>
<option value="2">Dictionary 2</option>
</select>
</div>
</div>
);
}
});
Everything seems ok, and I did a bunch of research about this, but nothing happens when the option is changed in the dropdown. The handleChange function is never called. Does anyone have any suggestions?
Thanks!
style="marginTop:'55px'}}>