@@ -15,6 +15,18 @@ import {
1515 MessageInputProps ,
1616} from '../MessageInput/MessageInput' ;
1717import { MessageListFlashList , MessageListFlashListProps } from '../MessageList/MessageFlashList' ;
18+ import { MessageListProps } from '../MessageList/MessageList' ;
19+
20+ // @ts -expect-error - FlashList is not defined in the global scope
21+ let FlashList ;
22+
23+ try {
24+ FlashList = require ( '@shopify/flash-list' ) . FlashList ;
25+ } catch ( e ) {
26+ console . error (
27+ 'The package @shopify/flash-list is not installed. Installing this package will enable the use of the FlashList component.' ,
28+ ) ;
29+ }
1830
1931type ThreadPropsWithContext = Pick < ChatContextValue , 'client' > &
2032 Pick < MessagesContextValue , 'MessageList' > &
@@ -36,7 +48,14 @@ type ThreadPropsWithContext = Pick<ChatContextValue, 'client'> &
3648 * Additional props for underlying MessageList component.
3749 * Available props - https://getstream.io/chat/docs/sdk/reactnative/ui-components/message-list/#props
3850 * */
39- additionalMessageListProps ?: Partial < MessageListFlashListProps > ;
51+ additionalMessageListProps ?: Partial < MessageListProps > ;
52+ /**
53+ * @experimental This prop is experimental and is subject to change.
54+ *
55+ * Additional props for underlying MessageListFlashList component.
56+ * Available props - https://shopify.github.io/flash-list/docs/usage
57+ */
58+ additionalMessageListFlashListProps ?: Partial < MessageListFlashListProps > ;
4059 /** Make input focus on mounting thread */
4160 autoFocus ?: boolean ;
4261 /** Closes thread on dismount, defaults to true */
@@ -58,13 +77,14 @@ const ThreadWithContext = (props: ThreadPropsWithContext) => {
5877 const {
5978 additionalMessageInputProps,
6079 additionalMessageListProps,
80+ additionalMessageListFlashListProps,
6181 autoFocus = true ,
6282 closeThread,
6383 closeThreadOnDismount = true ,
6484 disabled,
6585 loadMoreThread,
6686 MessageInput = DefaultMessageInput ,
67- // MessageList,
87+ MessageList,
6888 onThreadDismount,
6989 parentMessagePreventPress = true ,
7090 thread,
@@ -108,11 +128,20 @@ const ThreadWithContext = (props: ThreadPropsWithContext) => {
108128
109129 return (
110130 < React . Fragment key = { `thread-${ thread . id } ` } >
111- < MessageListFlashList
112- HeaderComponent = { MemoizedThreadFooterComponent }
113- threadList
114- { ...additionalMessageListProps }
115- />
131+ { /* @ts -expect-error - FlashList is not defined in the global scope */ }
132+ { FlashList ? (
133+ < MessageListFlashList
134+ HeaderComponent = { MemoizedThreadFooterComponent }
135+ threadList
136+ { ...additionalMessageListFlashListProps }
137+ />
138+ ) : (
139+ < MessageList
140+ FooterComponent = { MemoizedThreadFooterComponent }
141+ threadList
142+ { ...additionalMessageListProps }
143+ />
144+ ) }
116145 < MessageInput
117146 additionalTextInputProps = { {
118147 autoFocus,
0 commit comments