React: Autocomplete address fields

Asked by At

I'm working on react project,I'm trying to make a form where the user can fill in his address in separate fields (country, city, street, zip code, house number) with an autocomplete option, so that the possible city values are filtered based on the country value, the street possible values based on the country and the city, and so on. I tried to use react-places-autocomplete (react-places-autocomplete) that is based on Google Places API and add componentRestrictions to searchOptions prop like they did in this example Component restriction example. It works fine with just the country value, but when adding the postalCode key I receive an INVALID_REQUEST error from the API. So is it possible to restrict results from Google Places API by country, city, zip code and street? If yes what is the correct to do it? Is there another component React that allows to do this ? Thank you :)

0 Answers