Answer the question
In order to leave comments, you need to log in
How to add elements to select in react.js?
How to add elements to select in react.js?
<select >
<option value="1">Один</option>
<option value="2">Два</option>
</select>
Answer the question
In order to leave comments, you need to log in
Wrap the select weight in a separate component and re-render it every time there is new data. Something like this:
var Select = React.createClass({
getInitialState: function() {
return {
options: optionsService.getoptions()
};
},
renderOptions: function() {
return this.state.genres.map(function(genre, i){
return (
<option value={i} value={i}>Один</option>
)
})
},
render: function() {
return (
<select>
{ this.renderOptions() }
</select>
)
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question