TypeError: undefined is not an object (evaluating ....)
legaciespanda opened this issue · comments
When I fetch data from an API and save in the state array. When I try to use the data saved in the state. It shows me the error above.
The issue is on stack overflow https://stackoverflow.com/questions/65606216/react-native-deck-swiper
Looks like you have undefined cards. Try using a debugger in your card rendering method to see what are the card contents prior to throwing the error.
Alternatively you can update the card method to return card && (cardContent) || null which should fix the rendering issue if you get undefined or null cards.
Thanks
@webraptor
I was able to solve the problem with the code below
renderCard={(card) => (card && <Cardz card={card} />) || null}