Javascript react传单库中的地图组件给出;不变冲突:元素类型无效";错误
刚刚从1.9.1更新到2.0.0版本的《反应传单》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`. 我需要将反应
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
version16.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"