mattermost-mobile-upstream/app/routes/index.tsx
2026-08-19 01:35:52 +08:00

30 lines
967 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Redirect, type Href} from 'expo-router';
import {useEffect, useState} from 'react';
import {determineInitialExpoRoute, type ExpoRouterLaunchResult} from '@init/launch';
import {propsToParams} from '@screens/navigation';
export default function RootIndex() {
const [launchResult, setLaunchResult] = useState<ExpoRouterLaunchResult | null>(null);
useEffect(() => {
async function initializeLaunch() {
const result = await determineInitialExpoRoute();
setLaunchResult(result);
}
initializeLaunch();
}, []);
if (!launchResult) {
return null; // Still determining initial route
}
// Redirect to the determined route with params
const href: Href = {pathname: launchResult.route, params: propsToParams(launchResult.params)};
return <Redirect href={href}/>;
}