Skip to content
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

[Bug]: overwriting BottomSheet.onAnimate will reset snap index to 0 on rerender #2043

Open
Jacky56 opened this issue Nov 17, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Jacky56
Copy link

Jacky56 commented Nov 17, 2024

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

Android, Web

What happened?

overwriting BottomSheet.onAnimate will reset snap index to 0 on rerender

Reproduction steps

overwrite onAnimate method for BottomSheet with whatever then create an event which causes a rerender

Reproduction sample

https://snack.expo.dev/@kagutron/bottom-sheet---issue-reproduction-template

Relevant log output

No response

@Jacky56 Jacky56 added the bug Something isn't working label Nov 17, 2024
@hanwenbo
Copy link

Yes, there has been bug, you need to change the source code, when you operate fast, it will appear, you can prompt the user on the interface, please slow down :D

@IslamRustamov
Copy link

IslamRustamov commented Dec 6, 2024

The issue lies in handleOnAnimate function being a dependency for animateToPosition in @gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx

I didn't manage to find the reason how a dependency change retriggers animateToPosition (which retriggers something else and so on). Will look into that if I have time. But please do join me in this bugfixing.

UPDATE:
I found the reason why that is happening. handleOnAnimate recreates, which recreates animateToPosition, which recreates handleSnapToIndex, which is calling useEffect on this line . Which is basically why this bug happens. Will think of a fix for that.

UPDATE 1:
Here is the fix #2073

Copy link

github-actions bot commented Jan 7, 2025

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@IslamRustamov
Copy link

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants