简体   繁体   English

react-leaflet-heatmap-layer 抛出错误:TypeError:超级表达式必须是 null 或 function,未定义

[英]react-leaflet-heatmap-layer throwing error: TypeError: Super expression must either be null or a function, not undefined

I'm trying to use the react-leaflet-heatmap-layer module to add a heatmap to my react-leaflet map.我正在尝试使用 react-leaflet-heatmap-layer 模块向我的 react-leaflet map 添加热图。 I installed it via npm, and followed all the right steps, but I can't get the component to work.我通过 npm 安装了它,并遵循了所有正确的步骤,但我无法让组件工作。

There are two errors which I've come across:我遇到了两个错误:
1. Could not find a declaration file for module 'react-leaflet-heatmap-layer'. 1. 找不到模块“react-leaflet-heatmap-layer”的声明文件。

Could not find a declaration file for module 'react-leaflet-heatmap-layer'. 'path/node_modules/react-leaflet-heatmap-layer/lib/HeatmapLayer.js' implicitly has an 'any' type. Try `npm i --save-dev @types/react-leaflet-heatmap-layer` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-leaflet-heatmap-layer';`

@types isn't available for this module, so I tried to fix it by creating a global.d.ts file in the src folder, though I doubt I did it correctly because this error only seems to disappear when I have the.d.ts file open in my VSCode. @types 不适用于此模块,因此我尝试通过在 src 文件夹中创建 global.d.ts 文件来修复它,但我怀疑我是否正确地这样做了,因为这个错误似乎只有在我拥有 .d 时才会消失.ts 文件在我的 VSCode 中打开。 Other sources suggested editing the tsconfig.json file, but I couldn't find one, and I doubt my React project is even supposed to have one.其他消息来源建议编辑 tsconfig.json 文件,但我找不到,我怀疑我的 React 项目甚至应该有一个。

2. TypeError: Super expression must either be null or a function, not undefined This error shows up on the browser when I do npm start . 2. TypeError: Super expression must either be null or a function, not undefined当我执行npm start时,浏览器会出现此错误。 According to another source online, this error arose with a different leaflet module because it wasn't compatible with the updated versions of react, however I'm not sure if this is the error with my code as well.根据另一个在线消息来源,这个错误是由不同的 leaflet 模块引起的,因为它与更新版本的 react 不兼容,但是我不确定这是否也是我的代码的错误。 Here are the versions of react and the modules I'm using:以下是 react 的版本和我正在使用的模块:

"leaflet": "^1.7.1",
"leaflet.heat": "^0.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-leaflet": "^3.2.0",
"react-leaflet-heatmap-layer": "^2.0.0",

A lot of other sources online say that this error is most probably due to incorrectly importing the module, but I'm pretty certain I did everything the documentation told me to do.\ import HeatmapLayer from "react-leaflet-heatmap-layer";网上很多其他来源说这个错误很可能是由于错误地导入了模块,但我很确定我做了文档告诉我做的所有事情。\ import HeatmapLayer from "react-leaflet-heatmap-layer";

Please help.请帮忙。

A newer unofficial (?) version of react-leaflet-heatmap-layer has been published that is compatible with react-leaflet 3.x and 4. react-leaflet-heatmap-layer 的较新的非官方(?) 版本已发布,与 react-leaflet 3.x 和 4 兼容。

Note that publisher is not the original maintainer and the underlying source of this newer package is unclear.请注意,发布者不是原始维护者,并且这个较新的 package 的底层来源尚不清楚。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用webpack的react-redux给出错误Uncaught TypeError:超级表达式必须为null或函数,且未定义 - react-redux with webpack giving error Uncaught TypeError: Super expression must either be null or a function, not undefined Uncaught TypeError:超级表达式必须为null或函数,而不是react app中的未定义错误 - Uncaught TypeError: Super expression must either be null or a function, not undefined error in react app 反应本机错误-超级表达式必须为null或函数,且未定义 - React Native error - Super expression must either be null or a function, not undefined react-leaflet-rotatedmarkers:类型错误:超级表达式必须为null或函数,而不是对象 - react-leaflet-rotatedmarkers: TypeError: Super expression must either be null or a function, not object TypeError:超级表达式必须为null或函数,且未定义 - TypeError: Super expression must either be null or a function, not undefined 类型错误:超级表达式必须为空或反应本机中的函数_inherits - TypeError: Super expression must either be null or a function _inherits in react native TypeError:超级表达式必须是 null 或 React native 中的 function - TypeError: Super expression must either be null or a function in React native 未捕获的TypeError:超级表达式必须为null或函数,且未定义(React.js,Flux,ES6) - Uncaught TypeError: Super expression must either be null or a function, not undefined (React.js, Flux, ES6) React Native,TypeError:超级表达式必须为空或函数 - React Native, TypeError: Super expression must either be null or a function webpack、react 和 babel:未捕获的类型错误:超级表达式必须为 null 或函数,而不是未定义 - webpack, react and babel: Uncaught TypeError: Super expression must either be null or a function, not undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM