how do we use setComponentRestrictions for suggesstions base on countries list like ["us", ...]
tabvn opened this issue ยท 5 comments
tabvn commented
Hi Everyone
is there way to access native api and use func setComponentRestrictions
Best regards,
Toan
tabvn commented
i got answer
here is sample for someone need
const {
ready,
value,
suggestions: { status, data },
setValue,
clearSuggestions,
} = usePlacesAutocomplete({
requestOptions: {
/* Define search scope here */
componentRestrictions: { country: ["us", "vn"] },
},
debounce: 300,
});
adisak1618 commented
Not work for me I restrict country but still got results from all over the place
bandhanEA commented
^ same!!
joaodfmota commented
It's because the lib is using values in cache, if you clean up the session storage of the browser it will work as expected.
For now, I'm using this way:
cacheKey: 'br',
requestOptions: {
componentRestrictions: { country: 'br' },
},
bandhanEA commented
These are my request options that work for addresses in US
requestOptions: {
componentRestrictions: { country: 'us' },
types: ['address']
},
debounce: 300,
cache: 24 * 60 * 60
}