Home > Software design >  React JS App is showing "Uncaught (in promise) TypeError: Cannot read properties of undefined (
React JS App is showing "Uncaught (in promise) TypeError: Cannot read properties of undefined (

Time:10-14

My React app is showing the following error in the browser console:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 
    'indexOf')
    at WarningComponent.render (warning.js:1)
    at p._renderValidatedComponentWithoutOwnerOrContext (react-dom.min.js:13)
    at p._renderValidatedComponent (react-dom.min.js:13)
    at performInitialMount (react-dom.min.js:13)
    at p.mountComponent (react-dom.min.js:13)
    at Object.mountComponent (react-dom.min.js:14)
    at performInitialMount (react-dom.min.js:13)
    at p.mountComponent (react-dom.min.js:13)
    at Object.mountComponent (react-dom.min.js:14)
    at performInitialMount (react-dom.min.js:13)

My code does not use indexOf anywhere. I reinstalled node in a new directory and used create-react-app to create a new project. I also deleted my cache on Google Chrome. When I run this app, it shows the same error.

Is there a reason why I'm still seeing the same error? I don't think it can be because of my code. Maybe it is my dependencies in package.lock.json?

Thank you.

CodePudding user response:

I tested my code in a new browser (Safari) and the error did not show up. I reset my google chrome to default settings and it disappeared there as well. https://support.google.com/chrome/answer/3296214?hl=en

^ How to reset settings to default in Chrome

CodePudding user response:

At some point you are trying to go through a list with something like .map(), however, the thing isn't a list, for example, it might be a null value so there is no way to get "indexof" since there is no list to get the "index" (position in the list). The variable you are trying to go through is returning the value of "undefined"

  • Related