Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Country -> Province/State -> City selector?

I feel like this is pretty common that people want a selector that when you pick a country it narrows down province/states to that country then you pick state or province and it narrows down the city for you. Is there nothing on NPM for that? I saw country selector and country-province but nothing that goes from country to city. If nothing exists should I store all those in the DB or front-end? I'm assuming DB.

like image 566
Gooby Avatar asked Sep 10 '18 19:09

Gooby


3 Answers

You could use either of the two libraries.

  1. https://github.com/country-regions/react-country-region-selector [React Component -> Provides Country and State]
  2. https://www.npmjs.com/package/country-state-city, [Standalone Library which provides Country -> State -> City]

If you want to store the data and search results on your own, i would suggest you to stored it in a DB, loading the data on frontend would be expensive on network.

like image 175
Ayushya Avatar answered Nov 14 '22 23:11

Ayushya


You can use this React component react-places-autocomplete based on Google Places API.

like image 20
Philip Pavo Avatar answered Nov 15 '22 00:11

Philip Pavo


I would recommend using react country-state-city, but it consumes lot of space.

like image 23
Prayas Mittal Avatar answered Nov 14 '22 23:11

Prayas Mittal