Skip to content

Commit 3562681

Browse files
committed
fix: make FlashList component optional
1 parent 82dfa6b commit 3562681

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

examples/SampleApp/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,7 @@ PODS:
18591859
- ReactCommon/turbomodule/core
18601860
- SocketRocket
18611861
- Yoga
1862-
- react-native-cameraroll (7.10.2):
1862+
- react-native-cameraroll (7.10.0):
18631863
- boost
18641864
- DoubleConversion
18651865
- fast_float
@@ -3493,7 +3493,7 @@ SPEC CHECKSUMS:
34933493
React-Mapbuffer: 8f620d1794c6b59a8c3862c3ae820a2e9e6c9bb0
34943494
React-microtasksnativemodule: dcf5321c9a41659a6718df8a5f202af1577c6825
34953495
react-native-blob-util: a511afccff6511544ebf56928e6afdf837b037a7
3496-
react-native-cameraroll: 5c5fb716af11f6178dca48271ae065cd786a0a02
3496+
react-native-cameraroll: 8c3ba9b6f511cf645778de19d5039b61d922fdfb
34973497
react-native-document-picker: b37cf6660ad9087b782faa78a1e67687fac15bfd
34983498
react-native-geolocation: b7f68b8c04e36ee669c630dbc48dd42cf93a0a41
34993499
react-native-image-picker: 9bceb747cd6cde22a3416ffdc819d11b5b11f156

examples/SampleApp/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@react-navigation/drawer": "7.4.1",
3838
"@react-navigation/native": "^7.1.10",
3939
"@react-navigation/stack": "^7.3.3",
40+
"@shopify/flash-list": "^2.0.3",
4041
"emoji-mart": "^5.6.0",
4142
"lodash.mergewith": "^4.6.2",
4243
"react": "19.1.0",

examples/SampleApp/yarn.lock

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,6 +2620,13 @@
26202620
read-yaml-file "^2.1.0"
26212621
strip-json-comments "^3.1.1"
26222622

2623+
"@shopify/flash-list@^2.0.3":
2624+
version "2.0.3"
2625+
resolved "https://registry.yarnpkg.com/@shopify/flash-list/-/flash-list-2.0.3.tgz#222427d1e09bf5cdd8a219d0a5a80f6f1d20465d"
2626+
integrity sha512-jUlHuZFoPdqRCDvOqsb2YkTttRPyV8Tb/EjCx3gE2wjr4UTM+fE0Ltv9bwBg0K7yo/SxRNXaW7xu5utusRb0xA==
2627+
dependencies:
2628+
tslib "2.8.1"
2629+
26232630
"@sideway/address@^4.1.5":
26242631
version "4.1.5"
26252632
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.5.tgz#4bc149a0076623ced99ca8208ba780d65a99b9d5"
@@ -8443,16 +8450,16 @@ ts-api-utils@^2.1.0:
84438450
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-2.1.0.tgz#595f7094e46eed364c13fd23e75f9513d29baf91"
84448451
integrity sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==
84458452

8453+
[email protected], tslib@^2.1.0, tslib@^2.4.0:
8454+
version "2.8.1"
8455+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
8456+
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
8457+
84468458
tslib@^1.8.1:
84478459
version "1.14.1"
84488460
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
84498461
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
84508462

8451-
tslib@^2.1.0, tslib@^2.4.0:
8452-
version "2.8.1"
8453-
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
8454-
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
8455-
84568463
tsutils@^3.21.0:
84578464
version "3.21.0"
84588465
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"

package/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
},
6868
"dependencies": {
6969
"@gorhom/bottom-sheet": "^5.1.8",
70-
"@shopify/flash-list": "^2.0.3",
7170
"@ungap/structured-clone": "^1.3.0",
7271
"dayjs": "1.11.13",
7372
"emoji-regex": "^10.4.0",
@@ -86,6 +85,7 @@
8685
"@emoji-mart/data": ">=1.1.0",
8786
"@op-engineering/op-sqlite": ">=14.0.0",
8887
"@react-native-community/netinfo": ">=11.3.1",
88+
"@shopify/flash-list": ">=2.0.3",
8989
"emoji-mart": ">=5.4.0",
9090
"react-native": ">=0.73.0",
9191
"react-native-gesture-handler": ">=2.18.0",
@@ -96,6 +96,9 @@
9696
"@op-engineering/op-sqlite": {
9797
"optional": true
9898
},
99+
"@shopify/flash-list": {
100+
"optional": true
101+
},
99102
"emoji-mart": {
100103
"optional": true
101104
},
@@ -107,6 +110,7 @@
107110
"@babel/core": "^7.27.4",
108111
"@babel/runtime": "^7.27.6",
109112
"@op-engineering/op-sqlite": "^14.0.3",
113+
"@shopify/flash-list": "^2.0.3",
110114
"@react-native-community/eslint-config": "3.2.0",
111115
"@react-native-community/eslint-plugin": "1.3.0",
112116
"@react-native-community/netinfo": "^11.4.1",

package/src/components/MessageList/MessageFlashList.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ViewToken,
99
} from 'react-native';
1010

11-
import { FlashList, FlashListProps, FlashListRef } from '@shopify/flash-list';
11+
import { FlashListProps, FlashListRef } from '@shopify/flash-list';
1212
import type { Channel, Event, LocalMessage, MessageResponse } from 'stream-chat';
1313

1414
import { useMessageList } from './hooks/useMessageList';
@@ -46,6 +46,17 @@ import { ThreadContextValue, useThreadContext } from '../../contexts/threadConte
4646
import { useStableCallback } from '../../hooks';
4747
import { FileTypes } from '../../types/types';
4848

49+
// @ts-expect-error - FlashList is not defined in the global scope
50+
let FlashList;
51+
52+
try {
53+
FlashList = require('@shopify/flash-list').FlashList;
54+
} catch (e) {
55+
console.error(
56+
'The package @shopify/flash-list is not installed. Installing this package will enable the use of the FlashList component.',
57+
);
58+
}
59+
4960
const keyExtractor = (item: LocalMessage) => {
5061
if (item.id) {
5162
return item.id;
@@ -1113,6 +1124,13 @@ const MessageListFlashListWithContext = (props: MessageListFlashListPropsWithCon
11131124
);
11141125
}
11151126

1127+
// @ts-expect-error - FlashList is not defined in the global scope
1128+
if (!FlashList) {
1129+
throw new Error(
1130+
'The package @shopify/flash-list is not installed. Installing this package will enable the use of the FlashList component.',
1131+
);
1132+
}
1133+
11161134
return (
11171135
<View
11181136
onLayout={onLayout}

0 commit comments

Comments
 (0)