reactjs - How to use an array as option for react select component -


if wanna replace options

<option value="a">apple</option> <option value="b">banana</option> 

in given example use of array in react jsx file,how proceed ?

<select value="b">     <option value="a">apple</option>     <option value="b">banana</option> </select> 

best regards

blue

because it's javascript, there million ways. way take map container generate guts. loop or whatever work fine.

var answer = react.createclass({      render: function() {          var data     = ['this', 'example', 'isnt', 'funny'],             makeitem = function(x) {                 return <option>{x}</option>;             };           return <select>{data.map(makeitem)}</select>;      }  }; 

Comments