如何解决“未捕获类型错误:iterable.hasOwnProperty 不是函数”?

发布于 2025-01-11 09:11:33 字数 1417 浏览 0 评论 0原文

我正在尝试在代码中使用 react-leaflet-markerclusters 包。但是,在安装并运行 npm start 后,我收到此错误 (

loadMessages.js?4a62:4 Uncaught TypeError: iterable.hasOwnProperty is not a function
    at traverse (loadMessages.js?4a62:4:1)
    at loadMessages (loadMessages.js?4a62:25:1)
    at eval (Root.js?e933:41:13)
    at Module../src/masterApp/components/app/Root.js (bundle.js:49970:1)
    at __webpack_require__ (bundle.js:790:30)
    at fn (bundle.js:101:20)
    at eval (index.js?b635:1:1)
    at Module../src/index.js (bundle.js:49802:1)
    at __webpack_require__ (bundle.js:790:30)
    at fn (bundle.js:101:20)

) 和白屏。

我在应用程序中对 hasOwnProperty 进行了全局搜索,但没有结果。我假设这与外部包相关。经过进一步挖掘,它似乎与我在 Root.js 中导入的 loadMessages 相关。

以下是 Root.js 的片段:

import "core-js/stable";
import "regenerator-runtime/runtime";
import React from "react";
...
import { loadMessages, LocalizationProvider } from "@progress/kendo-react-intl";
import messages from "../../../assets/messages/messages";

loadMessages(messages.ar, "ar");
loadMessages(messages.en, "en");
loadMessages(messages.es, "es");
loadMessages(messages.fr, "fr");

我已尝试将 @progress/kendo-react-intl 更新到最新版本,但仍然收到 TypeError。 loadMessages 前面需要前缀吗?

如果有帮助,请注意我使用的是 Node 14.4.0 和 babel 7。更新此版本以上的 Node 会导致 Node-sass 错误。我应该降级 babel 吗?

I am trying to use the react-leaflet-markerclusters package in my code. However after installing it and running npm start, I am getting this error (

loadMessages.js?4a62:4 Uncaught TypeError: iterable.hasOwnProperty is not a function
    at traverse (loadMessages.js?4a62:4:1)
    at loadMessages (loadMessages.js?4a62:25:1)
    at eval (Root.js?e933:41:13)
    at Module../src/masterApp/components/app/Root.js (bundle.js:49970:1)
    at __webpack_require__ (bundle.js:790:30)
    at fn (bundle.js:101:20)
    at eval (index.js?b635:1:1)
    at Module../src/index.js (bundle.js:49802:1)
    at __webpack_require__ (bundle.js:790:30)
    at fn (bundle.js:101:20)

) and a white screen.

I did a global search in my application for hasOwnProperty and there are no results. I'm assuming this is tied to an external package. After further digging, it seems like it is tied to my loadMessages import in Root.js.

Here's a snippet of Root.js:

import "core-js/stable";
import "regenerator-runtime/runtime";
import React from "react";
...
import { loadMessages, LocalizationProvider } from "@progress/kendo-react-intl";
import messages from "../../../assets/messages/messages";

loadMessages(messages.ar, "ar");
loadMessages(messages.en, "en");
loadMessages(messages.es, "es");
loadMessages(messages.fr, "fr");

I've tried updating @progress/kendo-react-intl to the latest version but I still get the TypeError. Do I need a prefix in front of loadMessages?

If it helps any, please note that I am using node 14.4.0 and babel 7. Updating node beyond this version causes a node-sass error. Should I downgrade babel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

記憶穿過時間隧道 2025-01-18 09:11:33

我必须改变:

loadMessages(messages.ar, "ar");
loadMessages(messages.en, "en");
loadMessages(messages.es, "es");
loadMessages(messages.fr, "fr");

成为:

loadMessages(JSON.stringify(messages.ar), "ar");
loadMessages(JSON.stringify(messages.en), "en");
loadMessages(JSON.stringify(messages.es), "es");
loadMessages(JSON.stringify(messages.fr), "fr");

I had to change:

loadMessages(messages.ar, "ar");
loadMessages(messages.en, "en");
loadMessages(messages.es, "es");
loadMessages(messages.fr, "fr");

To be:

loadMessages(JSON.stringify(messages.ar), "ar");
loadMessages(JSON.stringify(messages.en), "en");
loadMessages(JSON.stringify(messages.es), "es");
loadMessages(JSON.stringify(messages.fr), "fr");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文