【发布时间】:2021-12-08 15:42:14
【问题描述】:
这是我的代码的样子:
import { React, useState, useEffect } from 'react';
import { GoogleMapReact } from 'google-map-react';
import styles from './Location.module.scss';
import pinstyles from './TheMap.module.scss';
import { useIntl } from 'react-intl';
/* This file has the actual with the coordinates passed to it */
const TheMap = (props) => {
// for holding the API key and language
const bootstrapURLKeys = {
//should this be french?
key: process.env.NEXT_PUBLIC_API_KEY,
language: 'en',
};
//const [test, setTest] = useState(false);
// const marker = new google.maps.Marker({
// position: props.center,
// map,
// });
// To do with the language of the map
const { formatMessage: f } = useIntl();
return (
<div className={styles.main}>
<div className={styles.heading}> {f({ id: 'location' })} </div>
<div className={styles.mapContainer}>
{/* TODO: The defaultZoom should be working but it isn't, not
a big deal but fix when there's time (it'll look better) */}
<GoogleMapReact
bootstrapURLKeys={bootstrapURLKeys}
defaultZoom={props.zoom}
center={props.center}
yesIWantToUseGoogleMapApiInternals
options={{ fullscreenControl: false }}
>
<Marker lat={props.lat} lng={props.lng} />
</GoogleMapReact>
</div>
{/* Adding the address to the bottom of the map */}
{props.location[1].address}
{props.location[1].postalCode}
</div>
);
};
const Marker = (props) => {
return (
<>
<div className={pinstyles.pin}></div>
<div className={pinstyles.pulse}></div>
</>
);
};
export default TheMap;
这是完整的错误:
未处理的运行时错误
错误:元素类型无效:应为字符串(对于内置 组件)或类/函数(用于复合组件),但得到: 不明确的。您可能忘记从文件中导出组件 它是在其中定义的,或者您可能混淆了默认导入和命名导入。
我想知道如何摆脱这个错误。
编辑:这是我的调用堆栈的样子:
【问题讨论】:
标签: javascript reactjs google-maps-api-3 runtime