Is it possible to change country dynamically?
png-prakash opened this issue · 1 comments
png-prakash commented
import useGoogle from "react-google-autocomplete/lib/usePlacesAutocompleteService";
import Constants from '../../lib/Constants';
const GoogleAddress = (props) => {
const [value, setValue] = useState("");
const {placesService, placePredictions, getPlacePredictions} = useGoogle({
apiKey: Constants.GOOGLE_ADDRESS_API_KEY,
options: {
componentRestrictions: { country: props.country },
},
});
When change the country in dropdown list is possible to get the addresses based on that particular country?
danielc1015 commented
@png-prakash You have two options:
- Lazy load the react component, so the initial value come from the previously selected country.
- You separately save in a useState const the options.
const [autocompleteOptions, setAutocompleteOptions] = useState({ componentRestrictions: { country: "cl" }, types: ["address"], })