1- import React , { useEffect } from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import { DevSettings , LogBox , Platform , useColorScheme } from 'react-native' ;
33import { createDrawerNavigator } from '@react-navigation/drawer' ;
44import { DarkTheme , DefaultTheme , NavigationContainer } from '@react-navigation/native' ;
@@ -58,6 +58,7 @@ Geolocation.setRNConfiguration({
5858import type { LocalMessage , StreamChat , TextComposerMiddleware } from 'stream-chat' ;
5959import { Toast } from './src/components/ToastComponent/Toast' ;
6060import { useClientNotificationsToastHandler } from './src/hooks/useClientNotificationsToastHandler' ;
61+ import AsyncStore from './src/utils/AsyncStore.ts' ;
6162
6263init ( { data } ) ;
6364
@@ -90,6 +91,7 @@ const Stack = createStackNavigator<StackNavigatorParamList>();
9091const UserSelectorStack = createStackNavigator < UserSelectorParamList > ( ) ;
9192const App = ( ) => {
9293 const { chatClient, isConnecting, loginUser, logout, switchUser } = useChatClient ( ) ;
94+ const [ messageListImplementation , setMessageListImplementation ] = useState < 'flashlist' | 'flatlist' | null > ( null ) ;
9395 const colorScheme = useColorScheme ( ) ;
9496 const streamChatTheme = useStreamChatTheme ( ) ;
9597
@@ -131,6 +133,14 @@ const App = () => {
131133 }
132134 }
133135 } ) ;
136+ const getMessageListImplementation = async ( ) => {
137+ const storedValue = await AsyncStore . getItem (
138+ '@stream-rn-sampleapp-messagelist-implementation' ,
139+ { id : 'flashlist' }
140+ ) ;
141+ setMessageListImplementation ( storedValue ?. id as ( 'flashlist' | 'flatlist' ) ) ;
142+ }
143+ getMessageListImplementation ( ) ;
134144 return ( ) => {
135145 unsubscribeOnNotificationOpen ( ) ;
136146 unsubscribeForegroundEvent ( ) ;
@@ -162,6 +172,10 @@ const App = () => {
162172 } ) ;
163173 } , [ chatClient ] ) ;
164174
175+ if ( ! messageListImplementation ) {
176+ return ;
177+ }
178+
165179 return (
166180 < SafeAreaProvider
167181 style = { {
@@ -180,7 +194,7 @@ const App = () => {
180194 dark : colorScheme === 'dark' ,
181195 } }
182196 >
183- < AppContext . Provider value = { { chatClient, loginUser, logout, switchUser } } >
197+ < AppContext . Provider value = { { chatClient, loginUser, logout, switchUser, messageListImplementation } } >
184198 { isConnecting && ! chatClient ? (
185199 < LoadingScreen />
186200 ) : chatClient ? (
0 commit comments