-
Notifications
You must be signed in to change notification settings - Fork 361
feat: optionally use FlashList using MessageFlashList component #3225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ve into feat/flashlist-implementation
…stream-chat-react-native into feat/flashlist-implementation
…stream-chat-react-native into feat/flashlist-implementation
SDK Size
|
| ); | ||
|
|
||
| /* | ||
| * TODO: Please rewrite this entire component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SecretMenu.tsx component is atrocious. It was initially added in a rush and is now modified in a rush. Even though it's just the SampleApp and it has no impact on anything performance related, it should be rewritten with a detached state whenever time allows it so that we can easily add more things to it in the future.
The Goal of the PR is to implement the MessageList using the FlashList v2 component. This comes under the
MessageFlashListcomponent which is a drop in replacement of theMessageListcomponent and is experimental in nature. This has some good performance implications for both Android and iOS as per our testing and the memory consumption is also way lesser that the FlatList alternative.This pull request introduces the new
MessageFlashListcomponent, which leverages@shopify/flash-listfor improved message list performance in React Native chat apps. It updates both example apps to useMessageFlashListinstead of the previousMessageList, adds support for the FlashList library throughout the codebase, and makes related dependency and configuration changes. Additionally, it introduces new props and utility functions to support the FlashList-based message list, and refines some styling and logic for message handling.Message List Rendering Improvements
MessageListwith the newMessageFlashListcomponent in both the ExpoMessaging and SampleApp example apps, improving performance and scalability for large message lists. (examples/ExpoMessaging/app/channel/[cid]/index.tsx,examples/SampleApp/src/screens/ChannelScreen.tsx) (examples/ExpoMessaging/app/channel/[cid]/index.tsxL3-R3, examples/ExpoMessaging/app/channel/[cid]/index.tsxL48-R48, [1] [2]Threadcomponent to conditionally renderMessageFlashListif@shopify/flash-listis available, and added an experimental prop for passing additional FlashList props. (package/src/components/Thread/Thread.tsx) [1] [2] [3] [4]MessageFlashListfrom the main components index for easier use. (package/src/components/index.ts)Dependency and Configuration Updates
@shopify/flash-listas a dependency in all relevantpackage.jsonfiles, marked it as optional where appropriate, and updated Jest setup to mock FlashList for tests. (examples/ExpoMessaging/package.json,examples/SampleApp/package.json,package/package.json,package/jest-setup.js) [1] [2] [3] [4] [5] [6]Message List Logic and Utilities
getLastReceivedMessageFlashListto efficiently find the last received or sending message in a list, supporting the FlashList implementation. (package/src/components/MessageList/utils/getLastReceivedMessageFlashList.ts)useMessageListhook to support anisFlashListparameter, adjusting how messages are ordered based on the list implementation. (package/src/components/MessageList/hooks/useMessageList.ts) [1] [2] [3]useShouldScrollToRecentOnNewOwnMessageto correctly identify the last message for scrolling when using FlashList. (package/src/components/MessageList/hooks/useShouldScrollToRecentOnNewOwnMessage.ts)Styling and Minor Adjustments
ChannelScreenand removed an Android-specific inversion style that is no longer needed. (examples/SampleApp/src/screens/ChannelScreen.tsx,package/src/components/MessageList/MessageList.tsx) [1] [2]