Newer
Older
import { Linking } from 'react-native';
import UserInactivity from 'react-native-user-inactivity';
import {observer} from "mobx-react";
import {useNavigation} from "@react-navigation/core";
import AgentProvider from '@aries-framework/react-hooks';
import MainStack from './MainStack';
import OnboardingStack from './OnboardingStack';
const RootStack: React.FC = observer(() => {
const navigation = useNavigation();
rootStore.agentStore.createAgent();
rootStore.urlStore.injectNavigation(navigation);
useEffect(() => {
(async () => {
const handleDeepLinking = (url: string) => {
rootStore.urlStore.setDeepLink(url);
};
Linking.addEventListener('url', ({ url }) => handleDeepLinking(url));
const initialUrl = await Linking.getInitialURL();
if (initialUrl) {
handleDeepLinking(initialUrl);
}
})();
}, []);
useEffect(() => {
if (rootStore.authenticated) {
rootStore.urlStore.processDeepLinkIfAny();
}
}, [rootStore.authenticated]);
return rootStore.agentStore.agentCreated && rootStore.authenticated ? (
onAction={isActive => {
rootStore.setAuthenticated(isActive);
}}
<AgentProvider agent={rootStore.agentStore.agent}>
<MainStack />
</AgentProvider>