populate react dropdown options from external json file code example
Example 1: how to load a drop down list in reactjs using json data
export const Cities = { cities : [ { Key: 1, Value: 'London' }, { Key: 2, Value: 'New York' }, { Key: 3, Value: 'Colombo' } ]}export default Cities;
Example 2: how to load a drop down list in reactjs using json data
<FormControl as="select" onChange={(e) => this.handleCities(e)}> {Cities.cities && Cities.cities.map((e, key) => { return <option key={key} value={e.Key}>{e.Value}</option>; })}