Skip to content

Cannot read property 'forEach' of undefined #10242

Open
@KovbenyaAlexander

Description

@KovbenyaAlexander

Hello
I created a project using npx create-react-app my-app. If i use npm start, compilation is successful, but the page is blank.
I have not made any changes to the project.
The console contains an error:

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

Screenshot:
2020-12-12 (2)

Activity

yves-zhou

yves-zhou commented on Dec 15, 2020

@yves-zhou

Today, I found this problem.

avihaymenahem

avihaymenahem commented on Dec 15, 2020

@avihaymenahem

Same here, running from npx here causes the same issue (no modifications maded)

EDIT:
A workaround for now so you can keep on working:
Disable the React DEV TOOLS extension on Chrome.

The problem comes from the global Hook which initiated wrong (Missing renderers prop on the object, which needs to be initiated with new Map())

KovbenyaAlexander

KovbenyaAlexander commented on Dec 15, 2020

@KovbenyaAlexander
Author

@avihaymenahem lol, I installed this extension and now the project is working correctly. but only in a browser with the extension

blockmood

blockmood commented on Dec 21, 2020

@blockmood

@KovbenyaAlexander Close the Browser react plugin。

albiummid

albiummid commented on Mar 3, 2021

@albiummid

@avihaymenahem lol, I installed this extension and now the project is working correctly. but only in a browser with the extension

that also worked for me. XD

arron-chen

arron-chen commented on Apr 17, 2021

@arron-chen

so did i,how to do?

arron-chen

arron-chen commented on Apr 17, 2021

@arron-chen

disabled the browser devtools will be fine, but i need this devtools to debug?

hechengxixi

hechengxixi commented on Apr 21, 2021

@hechengxixi

@arron-chen the same case with me. do you find better way to debug?

KevinAdu

KevinAdu commented on Feb 23, 2022

@KevinAdu

Did this issue ever get solved?

callisto1337

callisto1337 commented on Mar 21, 2022

@callisto1337

the same case

voidoperator

voidoperator commented on Jun 18, 2023

@voidoperator

i've been getting a similar error when clearing localStorage manually (which is set by a useEffect, the data stored is an object that i'm state managing with react's context API).

Uncaught TypeError: Cannot read properties of undefined (reading 'forEach')
    at setup (backendManager.js:656:17)
    at welcome (backendManager.js:640:3)
jarrodmjack

jarrodmjack commented on Jul 21, 2023

@jarrodmjack

@voidoperator I am getting this exact same issue with localstorage but cannot find a fix

Shaker-Hamdi

Shaker-Hamdi commented on Aug 3, 2023

@Shaker-Hamdi

I'm not even using "Create React App" and I'm getting the same issue with "Vite" and "Next.js".
I think it's a "React Dev Tool" issue.

idilTugba

idilTugba commented on Sep 16, 2023

@idilTugba
  • disable React Dev Tools plugin and refresh the localhost.
  • enable React Dev Tools
    everything working correctly now
thany

thany commented on Jun 7, 2024

@thany

I'm getting this error without the react devtools as well. All I have to do is access my website running om localhost, through BrowserStack. Not sure what is happening, but it should be easy to reproduce with any CRA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @thany@avihaymenahem@Shaker-Hamdi@KevinAdu@callisto1337

        Issue actions

          Cannot read property 'forEach' of undefined · Issue #10242 · facebook/create-react-app