1import React from 'react';
2import {ScrollView, Text} from 'react-native';
3
4const isCloseToBottom = ({layoutMeasurement, contentOffset, contentSize}) => {
5 const paddingToBottom = 20;
6 return layoutMeasurement.height + contentOffset.y >=
7 contentSize.height - paddingToBottom;
8};
9
10const MyCoolScrollViewComponent = ({enableSomeButton}) => (
11 <ScrollView
12 onScroll={({nativeEvent}) => {
13 if (isCloseToBottom(nativeEvent)) {
14 enableSomeButton();
15 }
16 }}
17 scrollEventThrottle={400}
18 >
19 <Text>Here is very long lorem ipsum or something...</Text>
20 </ScrollView>
21);
22
23export default MyCoolScrollViewComponent;
24