@@ -9,24 +9,25 @@ import type {
99 BottomSheetScrollableProps ,
1010} from './types' ;
1111
12- let FlashList : React . FC ;
13-
12+ let FlashList : {
13+ FlashList : React . FC ;
14+ } ;
15+ // since FlashList is not a dependency for the library
16+ // we try to import it using metro optional import
1417try {
15- FlashList = require ( '@shopify/flash-list' ) . FlashList as never ;
16- } catch ( _ ) {
17- throw 'You need to install FlashList first, `yarn install @shopify/flash-list`' ;
18- }
18+ FlashList = require ( '@shopify/flash-list' ) as never ;
19+ } catch ( _ ) { }
1920
2021export type BottomSheetFlashListProps < T > = Omit <
2122 Animated . AnimateProps < FlashListProps < T > > ,
2223 'decelerationRate' | 'onScroll' | 'scrollEventThrottle'
2324> &
2425 BottomSheetScrollableProps & {
25- ref ?: Ref < typeof FlashList > ;
26+ ref ?: Ref < React . FC > ;
2627 } ;
2728
2829const BottomSheetFlashListComponent = forwardRef <
29- typeof FlashList ,
30+ React . FC ,
3031 // biome-ignore lint/suspicious/noExplicitAny: to be addressed
3132 BottomSheetFlashListProps < any >
3233> ( ( props , ref ) => {
@@ -40,6 +41,12 @@ const BottomSheetFlashListComponent = forwardRef<
4041 } : any = props ;
4142 //#endregion
4243
44+ useMemo ( ( ) => {
45+ if ( ! FlashList ) {
46+ throw 'You need to install FlashList first, `yarn install @shopify/flash-list`' ;
47+ }
48+ } , [ ] ) ;
49+
4350 //#region render
4451 const renderScrollComponent = useMemo (
4552 ( ) =>
@@ -61,7 +68,7 @@ const BottomSheetFlashListComponent = forwardRef<
6168 [ focusHook , scrollEventsHandlersHook , enableFooterMarginAdjustment ]
6269 ) ;
6370 return (
64- < FlashList
71+ < FlashList . FlashList
6572 ref = { ref }
6673 renderScrollComponent = { renderScrollComponent }
6774 { ...rest }
0 commit comments