Tag Archives: :Uncaught TypeError: Cannot read property ‘forEach‘ of undefined

[Solved] React Project Start Error: Uncaught TypeError: Cannot read property ‘forEach‘ of undefined

If your react scaffold runs successfully, the page is white and there are the following errors in the console

Well, this is because your browser has installed the react devtools extension. Many people’s way is to disable react devtools directly. I suggest you not. After all, this plug-in is still very useful, and it’s really troublesome to install

Solution:

1. Change other browsers to preview [with Firefox]

2. Change code

Found in your project   node_ Modules/@ pmmmwh/react refresh webpack plugin

Comment out this line of code and restart the project!

At this time, the project can run normally and your plug-in can also be used

However, this method is cumbersome. It needs to be changed every time the scaffold is created, but this problem only exists in the new version of react. It seems that this problem does not exist in the old version

React Run Error: Uncaught TypeError: Cannot read property ‘forEach‘ of undefined

as the topic, the react project startup error, detailed information, as shown in the following:

: The React -DevTools extension is installed in the browser. Many people simply disable the React -DevTools extension. I think it’s OK, but I just don’t feel good. We installed this to see the React element and the compiled code. That seems like a tough way to do it, so I’ll just drop you.

my personal information, according to the error stack to find node_modules/@ PMMMWH/react – refresh – webpack – the plugin/client/ReactRefreshEntry js the file, find the error code, Comment directly the line that caused the error:

so, restart the project, the browser load the project correctly, there is no error message, and the react – devtools plug-in also normal load, good job:

this error, but also have a lot to do with the react version, remember too old version if it won’t appear this problem. This approach also does not solve the root cause of the problem, if the new project, or reinstall the dependencies, you still need to manually modify the code.