react-native-reanimated
react-native-reanimated copied to clipboard
useAnimatedScrollHandler with refreshControl not working
Description
useAnimatedScrollHandler is not working on Android with RefreshControl similar to https://github.com/software-mansion/react-native-reanimated/issues/3937
Steps to reproduce
<Animated.ScrollView
onScroll={scrollHandler}
refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}> {children} </Animated.ScrollView>
Snack or a link to a repository
https://snack.expo.dev/OAXfUmXwP1DilS_uErLED
Reanimated version
3.10.0
React Native version
0.74.1
Platforms
Android
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
Same issue on Android
Reanimated version
3.11.0
Does not even gets called.
const onScroll = useAnimatedScrollHandler({
onScroll: event => {
const currentOffset = event.contentOffset.y;
//Scroll not outside of top bounds
if (currentOffset > 0) {
isScrollingUp.value = scrollY.value > currentOffset;
scrollY.value = currentOffset;
isAtBottom.value =
currentOffset >=
event.contentSize.height - event.layoutMeasurement.height;
}
},
});
<Animated.FlatList
ListEmptyComponent={ListEmptyComponent}
ListHeaderComponent={<HomeHeader navigation={navigation} />}
ListFooterComponent={<HomeFooter />}
ref={flatListRef}
contentContainerStyle={styles.contentContainer}
showsVerticalScrollIndicator={false}
onScroll={onScroll}
onEndReached={hasMore ? onNextPage : null}
onEndReachedThreshold={2}
onRefresh={onRefresh}
refreshing={false}
scrollEventThrottle={16}
data={data}
keyExtractor={(item, index) => `${item.id}-${index}`}
renderItem={renderItem}
initialNumToRender={5}
removeClippedSubviews
/>
same issue here on Android
This patch fixes the issue on 3.11.0
Hello everyone, the patch @Ravnravn mentioned is already included in 3.12 version
- please upgrade Reanimated and it should be gone 👍