alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
1.56k stars 465 forks source link

TypeError: undefined is not an object (evaluating ....) #342

Closed legaciespanda closed 3 years ago

legaciespanda commented 3 years ago

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

webraptor commented 3 years ago

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.

legaciespanda commented 3 years ago

Thanks @webraptor I was able to solve the problem with the code below

renderCard={(card) => (card && <Cardz card={card} />) || null}

legaciespanda commented 3 years ago

Thanks, i have solved the issue. Issue closed

On Sat, 9 Jan 2021 at 05:54, Bogdan Pop notifications@github.com wrote:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alexbrillant/react-native-deck-swiper/issues/342#issuecomment-757096485, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKBFKNVJ5RFOBKZGUK3JO5DSY7ORTANCNFSM4V22WT7A .