hyochan / react-native-masonry-list

The Masonry List implementation which has similar implementation as the `FlatList` in React Native
MIT License
393 stars 55 forks source link

onEndReached doesn't trigger onEndReachedThreshold's exact scroll position. #41

Closed daseuls closed 1 year ago

daseuls commented 1 year ago

Describe the bug Hi, I want to make infinite scroll with onEndReachedThreshold and onEndReached. But when I use onEndReachedThreshold and onEndReached, it triggers onEndReachedThreshold's inaccurate scroll position. I add my code and video here.

  return (
    <SafeAreaView style={styles.container}>
      <MasonryList
        keyExtractor={(item, index): string => `${item.id}${index}`}
        numColumns={2}
        data={imageList}
        renderItem={({item}) => (
          <ImageItem item={item} onPressBookmarkBtn={onPressBookmarkBtn} />
        )}
        onEndReachedThreshold={0}
        onEndReached={() => console.log('onEndReached !')}
        onMomentumScrollBegin={() => setIsLoading(true)}
      />
    </SafeAreaView>
  );

Screenshots https://user-images.githubusercontent.com/71131248/179920395-b28b3aa2-7b6c-4b78-abbe-ab8aeb69a892.mp4

Desktop (please complete the following information):

Smartphone (please complete the following information):

hyochan commented 1 year ago

@daseuls Hello. Thanks for issuing this. I've just investigated the problem and this was caused by falsy detection in js when 0 is passed to props on onEndReachedThreshold.

I've managed to fix this in #43, which will be released to 1.3.2. Feel free to issue any other problems afterward.