wellyshen / use-places-autocomplete

😎 📍 React hook for Google Maps Places Autocomplete.
https://use-places-autocomplete.netlify.app
MIT License
1.26k stars 65 forks source link

Does getLatLng util really need to be async? #998

Closed RavenHursT closed 2 years ago

RavenHursT commented 2 years ago

Wondering why this is async? Is there some reason it has to be? 🤔

https://github.com/wellyshen/use-places-autocomplete/blob/master/src/utils.ts#L31-L40

I'm using this simple synchronous function in my code and it seems to be working fine. No need to call w/ await, or have an async consumer this way:

const getLatLng = (address = {}) => {
  const {
    geometry: {
      location: {
        lat = noop,
        lng = noop
      } = {}
    } = {}
  } = address

  return {
    lat: lat(),
    lng: lng()
  }
}
wellyshen commented 2 years ago

@RavenHursT Yea, you are right I think the getLatLng and getZipCode can be synced methods. Would you like to give me a PR for that?

RavenHursT commented 2 years ago

@wellyshen ☝️

wellyshen commented 2 years ago

@RavenHursT Awesome bro, will review it soon 🤩

wellyshen commented 2 years ago

Close due to #1002