Because it's just javascript, there are a million ways. The way I usually take is to map the container to generate the guts. A for loop or whatever would also work just fine.
const Answer = react.createClass({
render: function() {
var Data = ['this', 'example', 'isnt', 'funny'],
MakeItem = function(X) {
return <option>{X}</option>;
};
return <select>{Data.map(MakeItem)}</select>;
}
};
Or in es6 in more modern react you can just
const Answer = props =>
<select>{
props.data.map( (x,y) =>
<option key={y}>{x}</option> )
}</select>;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…