1
1
import * as React from 'react' ;
2
2
import { StyleSheet , Text , View , SectionList } from 'react-native' ;
3
- import { buildEventLogger } from '../utils/helpers' ;
3
+ import { customEventLogger , nativeEventLogger } from '../utils/helpers' ;
4
4
5
5
interface SectionData {
6
6
title : string ;
@@ -42,22 +42,7 @@ const sections: SectionData[] = [
42
42
} ,
43
43
] ;
44
44
45
- const handleMomentumScrollBegin = buildEventLogger ( 'momentumScrollBegin' ) ;
46
- const handleMomentumScrollEnd = buildEventLogger ( 'momentumScrollEnd' ) ;
47
- const handleScroll = buildEventLogger ( 'scroll' ) ;
48
- const handleScrollBeginDrag = buildEventLogger ( 'scrollBeginDrag' ) ;
49
- const handleScrollEndDrag = buildEventLogger ( 'scrollEndDrag' ) ;
50
- const handleScrollToTop = buildEventLogger ( 'scrollToTop' ) ;
51
-
52
45
export function SectionListEvents ( ) {
53
- const handleContentSizeChange = ( w : number , h : number ) => {
54
- console . log ( `Event: contentSizeChange` , w , h ) ;
55
- } ;
56
-
57
- const handleEndReached = ( info : { distanceFromEnd : number } ) => {
58
- console . log ( `Event: endReached` , info ) ;
59
- } ;
60
-
61
46
const renderSectionHeader = ( { section } : { section : SectionData } ) => (
62
47
< Text style = { styles . header } > { section . title } </ Text >
63
48
) ;
@@ -70,20 +55,20 @@ export function SectionListEvents() {
70
55
71
56
return (
72
57
< SectionList
73
- contentInsetAdjustmentBehavior = "scrollableAxes"
74
- scrollEventThrottle = { 150 }
75
58
sections = { sections }
76
59
keyExtractor = { ( item , index ) => item + index }
77
60
renderSectionHeader = { renderSectionHeader }
78
61
renderItem = { renderItem }
79
- onContentSizeChange = { handleContentSizeChange }
80
- onMomentumScrollBegin = { handleMomentumScrollBegin }
81
- onMomentumScrollEnd = { handleMomentumScrollEnd }
82
- onScroll = { handleScroll }
83
- onScrollBeginDrag = { handleScrollBeginDrag }
84
- onScrollEndDrag = { handleScrollEndDrag }
85
- onScrollToTop = { handleScrollToTop }
86
- onEndReached = { handleEndReached }
62
+ contentInsetAdjustmentBehavior = "scrollableAxes"
63
+ scrollEventThrottle = { 150 }
64
+ onScroll = { nativeEventLogger ( 'scroll' ) }
65
+ onScrollBeginDrag = { nativeEventLogger ( 'scrollBeginDrag' ) }
66
+ onScrollEndDrag = { nativeEventLogger ( 'scrollEndDrag' ) }
67
+ onMomentumScrollBegin = { nativeEventLogger ( 'momentumScrollBegin' ) }
68
+ onMomentumScrollEnd = { nativeEventLogger ( 'momentumScrollEnd' ) }
69
+ onScrollToTop = { nativeEventLogger ( 'scrollToTop' ) }
70
+ onEndReached = { customEventLogger ( 'endReached' ) }
71
+ onContentSizeChange = { customEventLogger ( 'contentSizeChange' ) }
87
72
/>
88
73
) ;
89
74
}
0 commit comments