@@ -9,24 +9,25 @@ import type {
9
9
BottomSheetScrollableProps ,
10
10
} from './types' ;
11
11
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
14
17
try {
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 ( _ ) { }
19
20
20
21
export type BottomSheetFlashListProps < T > = Omit <
21
22
Animated . AnimateProps < FlashListProps < T > > ,
22
23
'decelerationRate' | 'onScroll' | 'scrollEventThrottle'
23
24
> &
24
25
BottomSheetScrollableProps & {
25
- ref ?: Ref < typeof FlashList > ;
26
+ ref ?: Ref < React . FC > ;
26
27
} ;
27
28
28
29
const BottomSheetFlashListComponent = forwardRef <
29
- typeof FlashList ,
30
+ React . FC ,
30
31
// biome-ignore lint/suspicious/noExplicitAny: to be addressed
31
32
BottomSheetFlashListProps < any >
32
33
> ( ( props , ref ) => {
@@ -40,6 +41,12 @@ const BottomSheetFlashListComponent = forwardRef<
40
41
} : any = props ;
41
42
//#endregion
42
43
44
+ useMemo ( ( ) => {
45
+ if ( ! FlashList ) {
46
+ throw 'You need to install FlashList first, `yarn install @shopify/flash-list`' ;
47
+ }
48
+ } , [ ] ) ;
49
+
43
50
//#region render
44
51
const renderScrollComponent = useMemo (
45
52
( ) =>
@@ -61,7 +68,7 @@ const BottomSheetFlashListComponent = forwardRef<
61
68
[ focusHook , scrollEventsHandlersHook , enableFooterMarginAdjustment ]
62
69
) ;
63
70
return (
64
- < FlashList
71
+ < FlashList . FlashList
65
72
ref = { ref }
66
73
renderScrollComponent = { renderScrollComponent }
67
74
{ ...rest }
0 commit comments