Remove onScroll

This commit is contained in:
Dan Abramov
2023-12-08 20:06:56 +00:00
parent ed7deadf02
commit 339bfaae2d
+1 -19
View File
@@ -60,7 +60,7 @@ export const FlatList = React.forwardRef(function FlatListImpl<ItemT>(
contentContainerStyle,
onEndReached,
onEndReachedThreshold,
onScroll,
onScroll: _unused, // Not supported on the web.
ListHeaderComponent,
ListFooterComponent,
desktopFixedHeight,
@@ -115,24 +115,6 @@ export const FlatList = React.forwardRef(function FlatListImpl<ItemT>(
[],
)
React.useEffect(() => {
if (!onScroll) {
return
}
function handleScroll(e: any) {
;(onScroll as any).current?.worklet({
...e.nativeEvent,
eventName: 'onScroll',
contentOffset: {
x: 0,
y: window.scrollY,
},
})
}
window.addEventListener('scroll', handleScroll)
return () => window.removeEventListener('scroll', handleScroll)
}, [onScroll])
const onVisible = React.useCallback(() => {
onEndReached?.({
distanceFromEnd: onEndReachedThreshold || 0,