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

Add scrollTo examples for FlatList and FlashList #6207

Merged
merged 12 commits into from
Jul 9, 2024

Conversation

MatiPl01
Copy link
Member

@MatiPl01 MatiPl01 commented Jul 3, 2024

Summary

This PR adds FlatList and FlashList examples in the example app showing the usage of the scrollTo function. It also mentions the FlatList (yet only this) support in docs.

Example recordings

Paper Fabric
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-07-04.at.16.21.36.mp4
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-07-04.at.23.35.19.mp4

Remarks

  • FlashList supports scrollTo only on paper,
  • fabric doesn't support it yet. This PR will fix the issue.

@MatiPl01 MatiPl01 self-assigned this Jul 3, 2024
apps/common-app/src/App.tsx Outdated Show resolved Hide resolved
apps/common-app/package.json Outdated Show resolved Hide resolved
@MatiPl01 MatiPl01 marked this pull request as ready for review July 3, 2024 21:54
apps/common-app/package.json Outdated Show resolved Hide resolved
apps/fabric-example/android/app/build.gradle Outdated Show resolved Hide resolved
apps/common-app/src/examples/ScrollToFlashListExample.tsx Outdated Show resolved Hide resolved
@piaskowyk piaskowyk self-requested a review July 4, 2024 07:55
apps/common-app/package.json Outdated Show resolved Hide resolved
apps/fabric-example/android/settings.gradle Outdated Show resolved Hide resolved
apps/fabric-example/ios/Podfile Outdated Show resolved Hide resolved
Copy link
Contributor

@szydlovsky szydlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall nice work! Got some suggestions though

packages/docs-reanimated/docs/scroll/scrollTo.mdx Outdated Show resolved Hide resolved
apps/common-app/src/examples/ScrollToExample.tsx Outdated Show resolved Hide resolved
apps/common-app/src/examples/ScrollToExample.tsx Outdated Show resolved Hide resolved
@MatiPl01 MatiPl01 force-pushed the @matipl01/scrollTo-list-examples branch from 7222607 to 8e104f3 Compare July 4, 2024 21:42
Copy link
Contributor

@szydlovsky szydlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intuitive and clean, like it!

apps/common-app/src/App.tsx Outdated Show resolved Hide resolved
apps/common-app/src/App.tsx Outdated Show resolved Hide resolved
apps/common-app/src/examples/ScrollToExample.tsx Outdated Show resolved Hide resolved
apps/common-app/src/examples/ScrollToExample.tsx Outdated Show resolved Hide resolved
@MatiPl01 MatiPl01 requested a review from piaskowyk July 8, 2024 12:52
@MatiPl01 MatiPl01 requested a review from tomekzaw July 8, 2024 12:52
@MatiPl01 MatiPl01 added this pull request to the merge queue Jul 9, 2024
Merged via the queue into main with commit 4bff676 Jul 9, 2024
12 checks passed
@MatiPl01 MatiPl01 deleted the @matipl01/scrollTo-list-examples branch July 9, 2024 10:02
@Yusang-park
Copy link

@tomekzaw Scroll from UI is not working for FlashList.

@MatiPl01
Copy link
Member Author

@tomekzaw Scroll from UI is not working for FlashList.

Hey @Yusang-park!

It looks like they still haven't merged this PR from @j-piasecki which is required for the scrollTo to work properly. You can fix it on your side by patching the library. Please follow these steps:

  1. Add this method in node_modules/@shopify/flash-list/src/FlashList.tsx (e.g. below the getScrollableNode method):
  public getNativeScrollRef(): React.ElementRef<
    typeof ScrollViewComponent
  > | null {
    return this.rlvRef?.getNativeScrollRef?.() || null;
  }
  1. Add this to the node_modules/@shopify/flash-list/package.json:
"react-native": "src/index.ts",

It will ensure that the FlashList code is read from source files instead of the built js code in the dist directory.

I will ask someone from shopify if we can merge the necessary changes. I hope the next release of the flash-list will include these changes.

Let me know if it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants