npm install lodash.debounce
import debounce from 'lodash.debounce'
const doCityFilter = query => {
if (!query) return setFilteredCities([])
const debouncedFilter = debounce(() => {
console.log('====>', query)
setFilteredCities(citiesArray.filter(
city => city.toLowerCase().includes(query.toLowerCase())
))
}, 500)
debouncedFilter()
}
Top comments (0)