Answer the question
In order to leave comments, you need to log in
How to display given json list of cities in autocomplete?
Here is a link to the sanbox https://codesandbox.io/s/fristyr-react-gx25s
So.
Import json list.
I map it.import cities from 'cities.json';
const citiesList = cities;
const citiesListNames = citiesList.map( item => {
return item.name
} )
console.log(citiesListNames)
const options = [
{ value: 'Amsterdam', label: 'Amsterdam' },
{ value: 'London', label: 'London' },
{ value: 'Moscow', label: 'Moscow' },
];
<Select
value={selectedOption}
onChange={this.handleChange}
options={options}
name="city"
className={styles.weather_city_select}
/>
options={options}
const citiesListNames
but the application freezes from such an amount of data. Answer the question
In order to leave comments, you need to log in
const citiesListNames = citiesList.map( item => {
return item.name
} )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question