gpt4 book ai didi

javascript - react 谷歌地图 API :Cannot read properties of undefined reading 'emit'

转载 作者:行者123 更新时间:2023-12-05 00:38:45 31 4
gpt4 key购买 nike

我想在 google-map-react api 中包含 map ,但我总是收到以下错误:

google_map.js:428 Uncaught TypeError: Cannot read properties ofundefined (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;

最佳答案

似乎这解决了这个问题:
https://github.com/google-map-react/google-map-react/issues/1116#issuecomment-1150589667
否则,你可以扔你的next.config.(js/ts)

  reactStrictMode: false,

关于javascript - react 谷歌地图 API :Cannot read properties of undefined reading 'emit' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72062815/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com