最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Country -> ProvinceState -> City selector? - Stack Overflow

programmeradmin5浏览0评论

I feel like this is pretty mon 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.

I feel like this is pretty mon 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.

Share Improve this question edited Sep 11, 2018 at 8:31 Hyyan Abo Fakher 3,5273 gold badges24 silver badges36 bronze badges asked Sep 10, 2018 at 19:01 GoobyGooby 7333 gold badges15 silver badges38 bronze badges 1
  • 1 Did you find any package? How did you add this type of selector? – Arpit Commented Jan 3, 2019 at 11:44
Add a ment  | 

3 Answers 3

Reset to default 5

You could use either of the two libraries.

  1. https://github./country-regions/react-country-region-selector [React Component -> Provides Country and State]
  2. https://www.npmjs./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.

You can use this React ponent react-places-autoplete based on Google Places API.

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

发布评论

评论列表(0)

  1. 暂无评论