react-places-autocomplete
react-places-autocomplete copied to clipboard
Returning the full suggestion object in onSelect
Do you want to request a feature or report a bug? Feature
What is the current behavior?
onChange
and onSelect
(internally handleSelect
) only return limited data:
https://github.com/hibiken/react-places-autocomplete/blob/master/src/PlacesAutocomplete.js#L349
const { description, placeId } = suggestion;
this.handleSelect(description, placeId);
Why not return the full suggestion
object? At this moment, I can't get suggestion.terms
from these methods. The full suggestion
object is only available when rendering children
What is the expected behavior?
onChange
and onSelect
should return the full suggestion
object
Which versions of ReactPlacesAutocomplete, and which browser / OS are affected by this issue? react-places-autocomplete@^7.2.0
I agree that's a good question... It would be more useful ! And more consistent too 😅
I tried to fork it, but the source is not a compiled package. Not sure how to handle a non compiled node_module with webpacker :D Even tho my config uses babel-loader, my app can't find the package 🤔 While your package has the /dist folder
Can't you build it first ?
Do you mean Suggestion object, as the object data in which the place name comes from? So far I can only return address details, but I want to try and return the place details on click, such as place name and telephone number.
Fixed like this in my (private) fork :)
Looks like there's already a PR for this: #226. I would also love to see this feature!
Any progress with this one? I stupidly started using this without checking if it actually returned useful data, but with just the string it's not too handy.
Just merge the PR please! :)
If you want the structured address, you can use the util geocodeByPlaceId
and the placeId
to get the address_components
. That way you don't need to try and parse out the address yourself
I didn't even see this issue before implementing #319. Good to know that others will benefit from this as well :). It's currently in review and will be merged soon.
Related: #226