1- import type { ForwardedRef , ReactElement } from 'react' ;
2- import type { FlatListProps , FlatList as RNFlatList , ScrollViewProps } from 'react-native' ;
31import { Platform } from 'react-native' ;
42
5- import type { SendbirdMessage } from '@sendbird/uikit-utils' ;
6-
7- type FlatListBidirectional < T = SendbirdMessage > = ( props : FlatListProps < T > & BidirectionalProps < T > ) => ReactElement ;
8- type BidirectionalProps < T > = {
9- onStartReached ?: ( ( info : { distanceFromStart : number } ) => void ) | null | undefined ;
10- onStartReachedThreshold ?: number | null | undefined ;
11- onEndReached ?: ( ( info : { distanceFromEnd : number } ) => void ) | null | undefined ;
12- onEndReachedThreshold ?: number | null | undefined ;
13- maintainVisibleContentPosition ?: ScrollViewProps [ 'maintainVisibleContentPosition' ] ;
14- ref : ForwardedRef < RNFlatList < T > > ;
15- } ;
16-
173function shouldUseScrollViewEnhancer ( ) {
184 if ( Platform . constants . reactNativeVersion ?. major < 1 ) {
195 if ( Platform . constants . reactNativeVersion ?. minor < 72 ) {
@@ -22,17 +8,14 @@ function shouldUseScrollViewEnhancer() {
228 }
239 return false ;
2410}
25- function getFlatList ( ) : FlatListBidirectional {
26- if ( shouldUseScrollViewEnhancer ( ) ) {
27- try {
28- return require ( '@sendbird/react-native-scrollview-enhancer' ) . FlatList ;
29- } catch {
30- return require ( 'react-native' ) . FlatList ;
31- }
32- } else {
33- return require ( 'react-native' ) . FlatList ;
11+
12+ let FlatListInternal = require ( 'react-native' ) . FlatList ;
13+ if ( shouldUseScrollViewEnhancer ( ) ) {
14+ try {
15+ FlatListInternal = require ( '@sendbird/react-native-scrollview-enhancer' ) . FlatList ;
16+ } catch {
17+ FlatListInternal = require ( 'react-native' ) . FlatList ;
3418 }
3519}
3620
37- const FlatListInternal = getFlatList ( ) ;
3821export default FlatListInternal ;
0 commit comments