Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onPlaceSelected not being executed #229

Open
loixiyo opened this issue Jan 14, 2024 · 1 comment
Open

onPlaceSelected not being executed #229

loixiyo opened this issue Jan 14, 2024 · 1 comment

Comments

@loixiyo
Copy link

loixiyo commented Jan 14, 2024

Hi,

I have copy-pasted the code and the autocomplete service seems to be working. But the funcion onPlaceSelected is not being executed. Could you please help me? This is the code I'm using:

<Autocomplete
style={{ width: "90%" }}
options = {{
types: ['point_of_interest'],
fields: ["name", "formatted_address", "geometry", "place_id"],
componentRestrictions: { country: "es" }
}}
onPlaceSelected={(place) => {
console.log(place);
}}
/>

Thanks!

@loixiyo loixiyo changed the title onPlaceSelected not executing onPlaceSelected not being executed Jan 14, 2024
@meghana-ravikumar
Copy link

meghana-ravikumar commented Jan 30, 2024

Hi @loixiyo,

I faced the same issue, you can try adding apiKey={} property to the component. Something like this :

<Autocomplete
apiKey={API_KEY}
style={{ width: "90%" }}
options = {{
types: ['point_of_interest'],
fields: ["name", "formatted_address", "geometry", "place_id"],
componentRestrictions: { country: "es" }
}}
onPlaceSelected={(place) => {
console.log(place);
}}
/>

This fixed my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants