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

You have included the Google Maps JavaScript API multiple times on this page #1038

Closed martyjg closed 2 years ago

martyjg commented 2 years ago

Bug Report

I'm getting the following 2 errors when trying to use my autocomplete component:

You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors.

TypeError: Cannot read properties of undefined (reading 'Iv')

I'm following the getting started steps with loading the map script: const GOOGLE_MAPS_URL =https://maps.googleapis.com/maps/api/js?key=${process.env.NEXT_PUBLIC_PLACES_API_KEY}&libraries=places&callback=initMap`

This is happening as I'm trying to update react-dom to 18.1.0. The autocomplete does not work. The previous version major of react-dom doesn't give this error.

How to Reproduce

This is a next.js project.

  1. Follow the getting started steps
  2. Try to render page with the use-autocomplete

Your Environment

martyjg commented 2 years ago

I'm pretty sure it's related to React 18's StrictMode running useEffect twice.