How To Make Correctly Autocomplete In React
I want to make autocomplete input of cities in React. I have json
file of cities ~15mb. How should I correctly implement it? Should I keep this json
on client side?
Answer
you could make a request to the server on every keystroke but start the search after say 3 characters
e.g. searching for London
You would only make the first request after the user has typed in Lon
15mb seems a lot though, maybe you want to think of filtering this down beforehand so you request less countries back. e.g. make the user select a country beforehand so you only request cities in that country. so if they pick USA, then type in Chi
it would only return cities in the USA
starting with Chi
I don't think it's a good idea to pull the 15mb client side as that is a huge amount of data
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM