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

How to use scrollTo from Reanimated with FlashList without breaking recycling #941

Closed
2 tasks done
henrymoulton opened this issue Nov 3, 2023 · 1 comment
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@henrymoulton
Copy link

henrymoulton commented Nov 3, 2023

Current behavior

I'm working on some code where I can't rely on gestures responding to a ScrollView, so instead I'm using a Pan gesture handler to call scrollTo which I want to call on a ref to a scrollable, I want to use FlashList but I don't want to use ref.current.scrollToIndex as I believe it'd be called on the JS thread.

So I pass an Animated.ScrollView like this:

<FlashList
          renderScrollComponent={(props) => (
            <ForwardedScrollView
              {...props}
              ref={aref}
              onScroll={onScroll}
            />
          )}

and use that aref to call scrollTo on.

The problem is that I'm now scrolling the underlying scrollable but it's not updating the recycling, I've got a list of 6 items here but it's not updating:

bug.with.recycling.mov

Expected behavior

Is there a way to scrollToIndex using UI thread?

To Reproduce

https://snack.expo.dev/@henry12345678/delicious-violet-sandwich

Platform:

  • iOS
  • Android

Environment

"@shopify/flash-list": "1.4.3",
"react-native-gesture-handler": "~2.12.0",
"react-native-reanimated": "~3.3.0",
"expo": "~49.0.15",
"react-native": "0.72.6",

@henrymoulton henrymoulton added the bug Something isn't working label Nov 3, 2023
@henrymoulton
Copy link
Author

Have just seen software-mansion/react-native-reanimated#4384 and can confirm the example code works.

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

1 participant