I am trying to get put the data from an array to in react. I first retrieve the array from api response and store in state. Below is my code which fail to get the value but key to <select>?
temp_list = [
0:{fruit:"apple"},
1:{fruit:"orange"}]
const f_list = this.state.fruit
const tmp_list = Object.keys(f_list).map((item, index) => <option value={item.fruit} >{item.fruit}</option>);
The result of <select> option will b:
0
1
Expected:
apple
orange
How can I achieve what I want? Thanks
react-selectin the title. Can I assume that you are referring to aselectelement in a react environment, as opposed to thereact-selectlibrary?temp_listit may be like[ {fruit:"apple"}, {fruit:"orange"}]