Skip to content
Advertisement

useEffect shows data and then cannot read properties of undefined

I am getting data from a 3rd party API. When I console.log the data it shows in console but then is followed by Uncaught TypeError: Cannot read properties of undefined (reading 'tweet_results') I don’t actually get to see anything on the screen when I try the return as well, even though I have some conditions in there.

JavaScript

Advertisement

Answer

It seems like tweet_results can not contain in some objects from real data. So, to prevent from this error use ?. to go inside object.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement