11import * as React from 'react' ;
22import { StyleSheet , Text , View , SectionList } from 'react-native' ;
3- import { buildEventLogger } from '../utils/helpers' ;
3+ import { customEventLogger , nativeEventLogger } from '../utils/helpers' ;
44
55interface SectionData {
66 title : string ;
@@ -42,22 +42,7 @@ const sections: SectionData[] = [
4242 } ,
4343] ;
4444
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-
5245export 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-
6146 const renderSectionHeader = ( { section } : { section : SectionData } ) => (
6247 < Text style = { styles . header } > { section . title } </ Text >
6348 ) ;
@@ -70,20 +55,20 @@ export function SectionListEvents() {
7055
7156 return (
7257 < SectionList
73- contentInsetAdjustmentBehavior = "scrollableAxes"
74- scrollEventThrottle = { 150 }
7558 sections = { sections }
7659 keyExtractor = { ( item , index ) => item + index }
7760 renderSectionHeader = { renderSectionHeader }
7861 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' ) }
8772 />
8873 ) ;
8974}
0 commit comments