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

Change useMapsLibrary to return the library objects instead of a boolean #22

Closed
usefulthink opened this issue Oct 26, 2023 · 0 comments · Fixed by #26
Closed

Change useMapsLibrary to return the library objects instead of a boolean #22

usefulthink opened this issue Oct 26, 2023 · 0 comments · Fixed by #26

Comments

@usefulthink
Copy link
Collaborator

In order to be closer to the implementation in the google maps API, we want to change the returned type for the useMapsLibrary hook from boolean to the actual API Object returned by google.maps.importLibrary. At the same time we want to drop support for importing multiple libraries at once.

This removes the requirement to access the maps API via the global google.maps. variables (which seems to be something google wants to move away from in the long term).

So instead of

const libraryLoaded = useMapsLibrary('places');

useEffect(() =>{
  if (!libraryLoaded) return;

  const svc = new google.maps.places.PlacesService();
  // ...
}, [libraryLoaded]);

it would be

const placesLibrary = useMapsLibrary('places');

useEffect(() =>{
  if (!placesLibrary) return;

  const svc = new placesLibrary.PlacesService();
  // ...
}, [placesLibrary]);
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

Successfully merging a pull request may close this issue.

1 participant