diff --git a/packages/uikit-react-native/src/components/ChatFlatList/FlatListInternal.tsx b/packages/uikit-react-native/src/components/ChatFlatList/FlatListInternal.tsx index 8f83694a6..0ef2fe643 100644 --- a/packages/uikit-react-native/src/components/ChatFlatList/FlatListInternal.tsx +++ b/packages/uikit-react-native/src/components/ChatFlatList/FlatListInternal.tsx @@ -1,19 +1,5 @@ -import type { ForwardedRef, ReactElement } from 'react'; -import type { FlatListProps, FlatList as RNFlatList, ScrollViewProps } from 'react-native'; import { Platform } from 'react-native'; -import type { SendbirdMessage } from '@sendbird/uikit-utils'; - -type FlatListBidirectional = (props: FlatListProps & BidirectionalProps) => ReactElement; -type BidirectionalProps = { - onStartReached?: ((info: { distanceFromStart: number }) => void) | null | undefined; - onStartReachedThreshold?: number | null | undefined; - onEndReached?: ((info: { distanceFromEnd: number }) => void) | null | undefined; - onEndReachedThreshold?: number | null | undefined; - maintainVisibleContentPosition?: ScrollViewProps['maintainVisibleContentPosition']; - ref: ForwardedRef>; -}; - function shouldUseScrollViewEnhancer() { if (Platform.constants.reactNativeVersion?.major < 1) { if (Platform.constants.reactNativeVersion?.minor < 72) { @@ -22,17 +8,14 @@ function shouldUseScrollViewEnhancer() { } return false; } -function getFlatList(): FlatListBidirectional { - if (shouldUseScrollViewEnhancer()) { - try { - return require('@sendbird/react-native-scrollview-enhancer').FlatList; - } catch { - return require('react-native').FlatList; - } - } else { - return require('react-native').FlatList; + +let FlatListInternal = require('react-native').FlatList; +if (shouldUseScrollViewEnhancer()) { + try { + FlatListInternal = require('@sendbird/react-native-scrollview-enhancer').FlatList; + } catch { + FlatListInternal = require('react-native').FlatList; } } -const FlatListInternal = getFlatList(); export default FlatListInternal;