示例 DirectionsRenderer 正在崩溃
example DirectionsRenderer is crashing
我正在使用来自 https://tomchentw.github.io/react-google-maps/#!/DirectionsRenderer
的原始代码
我的组件:
export default class MyComponent extends React.Component {
render() {
return (
<main className="main--container">
<MapWithADirectionsRenderer />;
</main>
);
}}
在用 React 路由器渲染的容器中连接。
错误:
Uncaught TypeError: Cannot read property 'apply' of undefined
at eval (Recompose.js:831)
at eval (Recompose.js:831)
at eval (Recompose.js:831)
at eval (MyComponent.js:71)
at Object.<anonymous> (app.bundle.js:12417)
at __webpack_require__ (app.bundle.js:679)
at fn (app.bundle.js:89)
at eval (MyComponentContainer.js:14)
at Object.<anonymous> (app.bundle.js:12410)
at __webpack_require__ (app.bundle.js:679)
在任何页面上获取错误,即使未呈现 MapWithADirectionsRenderer
如果删除下一个代码,错误只会在我的容器页面上获取:
(props =>
<GoogleMap
defaultZoom={7}
defaultCenter={new google.maps.LatLng(41.8507300, -87.6512600)}
>
{props.directions && <DirectionsRenderer directions={props.directions} />}
</GoogleMap>
);
如果有人会遇到类似的问题,你应该像这样导入 withScriptjs
import withScriptjs from "react-google-maps/lib/async/withScriptjs";
我正在使用来自 https://tomchentw.github.io/react-google-maps/#!/DirectionsRenderer
的原始代码我的组件:
export default class MyComponent extends React.Component {
render() {
return (
<main className="main--container">
<MapWithADirectionsRenderer />;
</main>
);
}}
在用 React 路由器渲染的容器中连接。
错误:
Uncaught TypeError: Cannot read property 'apply' of undefined
at eval (Recompose.js:831)
at eval (Recompose.js:831)
at eval (Recompose.js:831)
at eval (MyComponent.js:71)
at Object.<anonymous> (app.bundle.js:12417)
at __webpack_require__ (app.bundle.js:679)
at fn (app.bundle.js:89)
at eval (MyComponentContainer.js:14)
at Object.<anonymous> (app.bundle.js:12410)
at __webpack_require__ (app.bundle.js:679)
在任何页面上获取错误,即使未呈现 MapWithADirectionsRenderer
如果删除下一个代码,错误只会在我的容器页面上获取:
(props =>
<GoogleMap
defaultZoom={7}
defaultCenter={new google.maps.LatLng(41.8507300, -87.6512600)}
>
{props.directions && <DirectionsRenderer directions={props.directions} />}
</GoogleMap>
);
如果有人会遇到类似的问题,你应该像这样导入 withScriptjs
import withScriptjs from "react-google-maps/lib/async/withScriptjs";