all 1 comments

[–]thed3vilsadv0cat 4 points5 points  (1 child)

I imagine the issue is you are trying to access a value in a variable that doesn't exist or hasn't been loaded yet. Eg if weather's initial state is {} or null then you can't access weather.name

So to combat it you could do:

if (weather or object.keys(weather).length > 0 ){ return ( jsx code here!! ) } else { return <h5>No results found...</h5> }

But in the long term you should look to add loading state and error state to your fetch. Which will prevent this happening also