Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript react传单库中的地图组件给出;不变冲突:元素类型无效";错误_Javascript_Reactjs_Leaflet_React Leaflet - Fatal编程技术网

Javascript react传单库中的地图组件给出;不变冲突:元素类型无效";错误

Javascript react传单库中的地图组件给出;不变冲突:元素类型无效";错误,javascript,reactjs,leaflet,react-leaflet,Javascript,Reactjs,Leaflet,React Leaflet,刚刚从1.9.1更新到2.0.0版本的《反应传单》react传单,出现了一个奇怪的错误: Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `Map`. 我需要将反应

刚刚从1.9.1更新到2.0.0版本的《反应传单》react传单,出现了一个奇怪的错误:

Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `Map`.
我需要将
反应传单
至少升级到第2版,以便我可以使用
带传单
功能在
反应传单
内渲染矢量分幅。相关职位:

在我的项目中包含
Map
组件的文件

import React, {Component} from "react";
import classNames from "classnames";
import {Map} from "react-leaflet";

class FdMap extends Component {
    mapRef = (map) => {
        if (map) {
            this.mapLeaflet = map.leafletElement;
            map.leafletElement.scrollWheelZoom.disable();

            map.leafletElement.on("focus", function () {
                map.leafletElement.scrollWheelZoom.enable();
            });

            map.leafletElement.on("blur", function () {
                map.leafletElement.scrollWheelZoom.disable();
            });
        }
    };

    render() {
        const {
          className,
          children
        } = this.props;
        const containerClassName = classNames(
          "fd-map",
          className
        );

        return (
            <Map ref={this.mapRef}
                 {...this.props}
                 className={containerClassName}>
                {children}
            </Map>
        );
    };
}

export default FdMap;

你有什么解决办法吗?

解决了这个问题。问题与
反应传单
道具
无关。似乎我正在使用
react dom
version
16.0.0
。将我的
react dom
版本更新为
16.4.1
,我的问题现在解决了。

如果删除子项,它会起作用吗?为什么要在
Map
中传递所有
props
?尝试删除子项。它不起作用:(@EdwardChopuryanI正在传递这些道具@JosephD.
{bounds:LatLngBounds{u southWest:LatLng,{u Northwest:Latling},boundsOptions:{padding:Array(2)},children:[{…},{…},{…},{…}],类名:“列出搜索地图”,minZoom:10,zoomControl:false}
这些实际上是与地图相关的道具。@BurakGüneli尝试逐个添加道具,看看是哪个道具导致了错误。
"react": "16.4.1",
"leaflet": "1.3.1"