I want to Include a map with the google-map-react api, but I always get the following error:
google_map.js:428 Uncaught TypeError: Cannot read properties of undefined (reading 'emit') at o.r.componentDidUpdate (google_map.js:428:1) at commitLayoutEffectOnFiber (react-dom.development.js:23232:1) at commitLayoutMountEffects_complete (react-dom.development.js:24578:1) at commitLayoutEffects_begin (react-dom.development.js:24564:1) at commitLayoutEffects (react-dom.development.js:24502:1) at commitRootImpl (react-dom.development.js:26779:1) at commitRoot (react-dom.development.js:26638:1) at finishConcurrentRender (react-dom.development.js:25937:1) at performConcurrentWorkOnRoot (react-dom.development.js:25765:1) at workLoop (scheduler.development.js:266:1)
import React from 'react'
import GoogleMapReact from 'google-map-react'
import {Paper, Typography, useMediaQuery} from '@material-ui/core'
import LocationOnOutlinedIcon from '@material-ui/icons/LocationOnOutlined';
import Rating from "@material-ui/lab"
import useStyles from './styles'
const Map = () =>{
const classes = useStyles();
const isMobile= useMediaQuery("(min-width:600px)");
const coords = {lat:0, lng:0}
const API_KEY = "############"
return(
<div className={classes.mapContainer}>
<GoogleMapReact
bootstrapURLKeys={{ key: API_KEY }}
defaultCenter={coords}
center={coords}
defaultZoom={14}
margin={[50, 50, 50, 50]}>
</GoogleMapReact>
</div>
)
}
export default Map;
Seems that this solves the issue:
https://github.com/google-map-react/google-map-react/issues/1116#issuecomment-1150589667
Otherwise, you can do it throw your next.config.(js/ts)
reactStrictMode: false,