Skip to content
Advertisement

React.js TypeError: Cannot read property ‘map’ of null

I m not sure how can i explain it. But i will do my best. I’m developing a Movie App. I dont have problem about receiving data and viewing it on the screen. Besides i can see my errors on screen like “Too Many Results” but it’s working only on main page. When i’m doing my searching like only series. I have another page for it. I dont have problem about receiving data and viewing it on the screen. But i cant see my error codes.

Fetch Page

JavaScript

Context page

JavaScript

SearchFormType page

JavaScript

Series page

JavaScript

I don’t know if it’s necessary but My home page

JavaScript

for last My main SearchForm

JavaScript

Advertisement

Answer

If you read the error message, it says you’re trying to call .map() on null value. In your code there’s two places where it could be:

JavaScript

Even if you’re having trouble getting stack traces, you can figure out which spot is causing the error by logging the value of movies.

JavaScript

It’s possible that global context starts off with null movies or useFetch defaults to null movies while the request is pending.

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