无法读取未定义的属性“forEach”(React)

Kov*_*der 3 reactjs


今天我开始学习react!我遇到了困难。

我使用创建了一个项目npx create-react-app my-app。如果我使用npm start,该应用程序将无法运行。我没有对项目进行任何更改

控制台包含此错误:

react-refresh-runtime.development.js:465 Uncaught TypeError: Cannot read property 'forEach' of undefined
    at Object.injectIntoGlobalHook (react-refresh-runtime.development.js:465)
    at Object../node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js (ReactRefreshEntry.js:8)
    at __webpack_require__ (bootstrap:856)
    at fn (bootstrap:150)
    at Object.1 (reportWebVitals.js:14)
    at __webpack_require__ (bootstrap:856)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1
Run Code Online (Sandbox Code Playgroud)

我该如何修复这个错误?

des*_*ant 6

这个问题似乎已经存在了几个月了,吸引了那些刚接触 Create React App 的人。这是相当不幸的,但根据您的 CRA 版本,解决方案是:

  • 安装 React 开发工具插件
  • 更新 React 开发工具插件
  • 卸载/禁用 React Dev Tools 插件

我已在这里记录: https ://github.com/facebook/create-react-app/issues/10500