TypeError: Cannot read properties of undefined (reading 'dispose')
After upgrading to react@18 my google maps crashing on render.
Component code:
import GoogleMapReact from "google-map-react";
import markerSvg from "../../assets/images/google_maps_mark.svg";
const { REACT_APP_PUBLIC_GOOGLE_MAPS_API_KEY } = process.env;
const Map = ({ lat, lng})=> {
return (
<div style={{ height: "400px", width: "400px" }}>
<GoogleMapReact
bootstrapURLKeys={{ key: REACT_APP_PUBLIC_GOOGLE_MAPS_API_KEY}}
defaultCenter={{ lat, lng }}
defaultZoom={11}
>
<img
src={markerSvg}
lat={lat}
lng={lng}
text="My Marker"
alt="marker"
/>
</GoogleMapReact>
</div>
);
}
export default Map;
Errors screenshots https://ibb.co/bsGV76c https://ibb.co/ZGBhV8B https://ibb.co/X5vNTt5
OS: [mac] Browser [any browser]
Any updates?!? I am also having the same issue....
same issue
Try removing <React.StrictMode></React.StrictMode> from your index.js file
Same issue
Hi. Is there any way to fix it without removing <React.StrictMode> from index.js file? Thanks
Does anyone have the same problem in vite?
I'm having the same issue. I noticed it occurs when changing the route and the current react component that has the GoogleMapReact is being destroyed (I hope this might help to solve it)
Does anyone have the same problem in vite?
I'm experiencing this with Vite right now.
Try removing Suspense & lazy loading
Yes, same issue here with Vite. We have to remove React.StrictyMode to make it work.
Hi. Is there any way to fix it without removing
<React.StrictMode>fromindex.jsfile? Thanks
this repo is i think pretty much dead. i would recommend anyone stumble upon this to try --> https://github.com/JustFly1984/react-google-maps-api
I had to change and use '@react-google-maps/api' which worked perfectly fine
The introduction of lazy loading and suspense to my project caused the issue to occur when changing routes and the current react component that has the GoogleMapReact is being destroyed.