-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting state in onSwipeRequirementFulfilled breaks animation in mobile browser #151
Comments
Ok, good catch! Unfortunately, I don't have time to look at this right now but PRs are accepted. |
As a workaround - put TinderCard in React's useMemo. Working flawlessly for me. Btw, the issue happened to me also in desktop. |
Hey @ikesler do you mind elaborating or giving a snippet of how you did it? |
The code was a bit specific to my project, here is the simplified version:
And yes - we've switched to entirely different UX eventually, so I do not use swipes anymore |
Ah, thanks for sharing |
No worries if no time to address - but noting that I'm experiencing the same issue. And I'm not sure memoizing will help, since I'd like to be able to change the internal state of the card to color it according to swipe left or right. |
For what it's worth, I was able to work around this for now by memoizing the .swipe-direction-right .my-card-background {
background-color: green;
} |
Whenever I try to call a react state setter from within the
onSwipeRequirementFulfilled
callback, the card animation breaks for mobile browsers. The card seems to re-render and stops being dragged. You can keep holding the screen down and the callback keeps getting called, but the card is no longer being dragged. **This is only visible on mobile browsers or devtools mobile view.I forked the demo repo to display this bug:
The text was updated successfully, but these errors were encountered: