Skip to content

Commit 213cbd3

Browse files
committed
fix: make flashlist optional
1 parent 1d5bbd3 commit 213cbd3

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

examples/TypeScriptMessaging/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"@react-native-documents/picker": "^10.1.3",
1919
"@react-navigation/native": "^7.1.10",
2020
"@react-navigation/stack": "^7.3.3",
21-
"@shopify/flash-list": "^2.0.3",
2221
"react": "19.1.0",
2322
"react-native": "0.80.2",
2423
"react-native-audio-recorder-player": "^3.6.13",

examples/TypeScriptMessaging/yarn.lock

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,13 +1904,6 @@
19041904
read-yaml-file "^2.1.0"
19051905
strip-json-comments "^3.1.1"
19061906

1907-
"@shopify/flash-list@^2.0.3":
1908-
version "2.0.3"
1909-
resolved "https://registry.yarnpkg.com/@shopify/flash-list/-/flash-list-2.0.3.tgz#222427d1e09bf5cdd8a219d0a5a80f6f1d20465d"
1910-
integrity sha512-jUlHuZFoPdqRCDvOqsb2YkTttRPyV8Tb/EjCx3gE2wjr4UTM+fE0Ltv9bwBg0K7yo/SxRNXaW7xu5utusRb0xA==
1911-
dependencies:
1912-
tslib "2.8.1"
1913-
19141907
"@sideway/address@^4.1.5":
19151908
version "4.1.5"
19161909
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.5.tgz#4bc149a0076623ced99ca8208ba780d65a99b9d5"
@@ -7597,16 +7590,16 @@ ts-api-utils@^2.1.0:
75977590
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-2.1.0.tgz#595f7094e46eed364c13fd23e75f9513d29baf91"
75987591
integrity sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==
75997592

7600-
[email protected], tslib@^2.4.0:
7601-
version "2.8.1"
7602-
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
7603-
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
7604-
76057593
tslib@^1.8.1:
76067594
version "1.14.1"
76077595
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
76087596
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
76097597

7598+
tslib@^2.4.0:
7599+
version "2.8.1"
7600+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
7601+
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
7602+
76107603
tsutils@^3.21.0:
76117604
version "3.21.0"
76127605
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"

package/src/components/Thread/Thread.tsx

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ import {
1515
MessageInputProps,
1616
} from '../MessageInput/MessageInput';
1717
import { 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

1931
type 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

Comments
 (0)