npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-infinite-flatlist-patch

v1.1.2

Published

Patch for infinite scrolling with FlatList

Downloads

59

Readme

NPM Version

Infinite scrolling is one of the most used UX in App. In React Native, This is implemented using the onEndReached props of FlatList.

Unfortunately, It doesn't work well as expected. I think it's one of the headaches that hasn't been solved for quite some time. We had to make it work by modifying onEndReachedThreshold several times, but eventually it doesn't work efficiently.

Now, This patch will make it work as you expect! It's too easy to use.

History

My PR is in progress, but React Native may not be easy to apply because there are so many things to consider. So, I decided to provide this patch for those who needed it.

Usage

Install

Once installed, react-native's FlatList is automatically patched.

yarn add react-native-infinite-flatlist-patch --dev

prepare should be added to prevent this patch from being restored whenever packages are changed.

{
  ...
  "scripts": {
    ...,
    "prepare": "yarn run infinite-flatlist-patch"
  }
}

If you were already using prepare, you can add the patch script later.

"prepare": "yarn run jetify; yarn run infinite-flatlist-patch"

Execute manually

You can execute the patch manually with the command below.

yarn run infinite-flatlist-patch

Uninstall

Just delete the command you added to prepare and remove my package.

Check out the improvements

You can test it yourself with this test app.

This app is to test the improvements of onEndReached of FlatList.

  • The list has 20 items at the beginning.
  • When onEndReached is called, 10 items are added.

After the initial rendering

# Official FlatList

Official FlatList initial rendering

OnEndReached is called and FlatList has 30 items.

# Patched FlatList

Patched FlatList initial rendering

OnEndReached is not called and FlatList has 20 items.

After scrolling to the 11th item

# Official FlatList

Official FlatList scrolling

OnEndReached is called twice in a short period and FlatList has 50 items.

# Patched FlatList

Patched FlatList scrolling

OnEndReached is called and FlatList has 30 items.