【发布时间】:2019-03-22 13:46:57
【问题描述】:
我正在从 react-leaflet 导入 Popup
import { Marker, Map, Popup, TileLayer, ZoomControl, GeoJSON, ScaleControl} from 'react-leaflet'
并试图扩展它
class NewPopup extends Popup {
onPopupOpen = ({ popup }: { popup: LeafletElement }) => {
if (popup === this.leafletElement) {
console.log("Here open");
this.onOpen()
}
}
onPopupClose = ({ popup }: { popup: LeafletElement }) => {
if (popup === this.leafletElement) {
console.log("Here close");
this.onClose()
}
}
}
这编译得很好,但是当我在浏览器中运行它时,我收到错误“超级表达式必须为空或函数,而不是对象”
当我控制台记录 Popup 对象时,它看起来像这样
{$$typeof: Symbol(react.forward_ref), render: ƒ, apply: ƒ, bind: ƒ, call: ƒ, …}
而不是 React 组件。我需要以不同的方式导入它吗?
【问题讨论】:
标签: javascript reactjs