import analytics from '@react-native-firebase/analytics'; import {NavigationContainer} from '@react-navigation/native'; import React, {useRef, useState} from 'react'; import {Provider} from 'react-redux'; import {StreamChat} from 'stream-chat'; import {OverlayProvider} from 'stream-chat-react-native'; import {STREAM_CHAT_API} from './constants'; import {getActiveRouteName} from './RootNavigation'; import {navigationRef} from './RootNavigation'; import Routes from './routes'; import store from './store/configureStore'; import { ChannelGroupedType, ChatContextType, LocalAttachmentType, LocalChannelType, LocalCommandType, LocalEventType, LocalMessageType, LocalResponseType, LocalUserType, } from './types'; import {isIPhoneX} from './utils'; export const ChatContext = React.createContext({} as ChatContextType); const App = () => { const routeNameRef = useRef(); const [channel, setChannel] = useState(); const chatClient = StreamChat.getInstance< LocalAttachmentType, LocalChannelType, LocalCommandType, LocalEventType, LocalMessageType, LocalResponseType, LocalUserType >(STREAM_CHAT_API); return ( { const previousRouteName = routeNameRef.current; const currentRouteName = getActiveRouteName(state); if (previousRouteName !== currentRouteName) { await analytics().logScreenView({ screen_name: currentRouteName, screen_class: currentRouteName, }); } routeNameRef.current = currentRouteName; }}> ); }; export default App;