alexandre-garrec / react-swipe-card

Tinder style swipe cards
https://alexandre-garrec.github.io/react-swipe-card
136 stars 79 forks source link

setState in onEnd() #16

Open atoulous opened 6 years ago

atoulous commented 6 years ago

Hello alex!

Thanks for the package, it's works well for me.

I had one question, what's the way to 'setState' in function onEnd of Cards component?

The code looks like that in my onEnd():

if (action === 'end') {
    this.setState({ users: null });
}

but i had this warning that informs me i updated state in unmounted component (in your SwipeCards):

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the SwipeCards component.

My point is I want to setState my current component, that contains Cards && Card, in onEnd function to re-render my view with updates without warnings, any idea ? 😃