React JS map function throwing error cannot read properties of null solution. How to fix map function null error in React JS.
If the array we are going to map is null then such an error may be thrown. Mostly with API calls when there is a delay in getting data.
eg:
We can fix this by adding a condition like if the array exists with data then do the map functions.
We can do that by adding data && data.map()
So this is the solution of Cannot read properties of null error in React JS.