import React, { forwardRef, memo, type Ref, useMemo } from 'react'; import type { FlatListProps, ScrollViewProps } from 'react-native'; import type { AnimatedProps } from 'react-native-reanimated'; import BottomSheetScrollView from './BottomSheetScrollView'; import type { BottomSheetScrollableProps, BottomSheetScrollViewMethods, } from './types'; /** * Minimal subset of FlashListProps needed for BottomSheetFlashList. * Defined locally to avoid requiring @shopify/flash-list as a dependency, * since the runtime import is optional (try/catch require). */ interface FlashListProps extends FlatListProps { estimatedItemSize?: number; } let FlashList: { FlashList: React.FC; }; // since FlashList is not a dependency for the library // we try to import it using metro optional import try { FlashList = require('@shopify/flash-list') as never; } catch (_) {} export type BottomSheetFlashListProps = Omit< AnimatedProps>, 'decelerationRate' | 'onScroll' | 'scrollEventThrottle' > & BottomSheetScrollableProps & { ref?: Ref; }; const BottomSheetFlashListComponent = forwardRef< React.FC, // biome-ignore lint/suspicious/noExplicitAny: to be addressed BottomSheetFlashListProps >((props, ref) => { //#region props const { focusHook, scrollEventsHandlersHook, enableFooterMarginAdjustment, ...rest // biome-ignore lint: to be addressed! }: any = props; //#endregion useMemo(() => { if (!FlashList) { throw 'You need to install FlashList first, `yarn install @shopify/flash-list`'; } console.warn( 'BottomSheetFlashList is deprecated, please use useBottomSheetScrollableCreator instead.' ); }, []); //#region render const renderScrollComponent = useMemo( () => forwardRef( // @ts-expect-error ({ data, ...props }, ref) => { return ( // @ts-expect-error ); } ), [focusHook, scrollEventsHandlersHook, enableFooterMarginAdjustment] ); return ( ); //#endregion }); export const BottomSheetFlashList = memo(BottomSheetFlashListComponent); export default BottomSheetFlashList as ( props: BottomSheetFlashListProps ) => ReturnType;