TypeError: Cannot read properties of undefined (reading 'map') in react dev

39 Views Asked by At

in this the code is working normally when the api call is not done but when i make the call then it first render the normal code but after the api call it's not re-render the fetched data.

enter image description here enter image description here

please describe me the problem and how can i solve this as i am beginner in the react.

1

There are 1 best solutions below

0
Sourabh Chopade On BEST ANSWER

Try adding a null check whenever you are calling map function.

filteredRestaurant?.map(x => <RestaurantCard  />)