-1

我正在使用来自https://tomchentw.github.io/react-google-maps/#!/DirectionsRenderer的原始代码

我的组件:

export default class MyComponent extends React.Component {
render() {
    return (
        <main className="main--container">
            <MapWithADirectionsRenderer />;
        </main>
    );
}}

它连接在容器中,用反应路由器渲染。

错误:

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>
);
4

1 回答 1

0

如果有人会遇到类似的问题,你应该像这样导入 withScriptjs

import withScriptjs from "react-google-maps/lib/async/withScriptjs";
于 2017-12-27T10:45:56.273 回答