I am trying to set the initial navigation theme based on the current route params. But I have to render the NavigationContainer to access the ref to gain information aboute the route, which leads to a flash of content with the default theme. Can I access the route without the ref from outside of the NavigationContainer somehow?
Here is what i tried, which leads to a flash of unthemed content:
export default function AuthNavigator() { const { theme: { navigation: navigationTheme }, setThemeByTenantId } = useContext(ThemeContext) // auth stuff // set custom theme on initial load useEffect(()=> { if (navigationRef.current?.getState()) { const route = navigationRef.current?.getState().routes[0] if (route && route.params && route.params.tenantId) { setThemeByTenantId(route.params.tenantId) } } },[navigationRef.current]) return (<View style={styles.container}><NavigationContainer ref={navigationRef} initialState={initialState} onStateChange={handleStateChange} theme={navigationTheme} linking={linking}> { signedIn ?<UserProvider><SignedInStack /></UserProvider> :<SignedOutStack /> }</NavigationContainer></View> )}