Home > Net >  Cannot read properties of null (reading 'map')
Cannot read properties of null (reading 'map')

Time:09-14

enter image description here

this is my code why I am facing this error my use state is also not null enter image description here

CodePudding user response:

videos is not an array when you're calling it. You can do a type of check to check if it's an array or check if it's not null.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray

CodePudding user response:

There is a possibility that the Videos component is not getting a video as props. So to overcome the situation you can use

videos?.map()

So basically just add a question mark

return (
        <>
           { videos && <Stack direction='row' ... >}
        </>
       )

  • Related