Я пытаюсь изменить текущий стек. Я пытаюсь изменить стек, когда пользователь вошел в систему, но изменения не отображаются. Загрузка компонента всегда отображается ...
Навигация. js
import React from "react";
import { createAppContainer, createSwitchNavigator } from "react-navigation";
import NavigationStacksLogged from "./NavigationLogged";
import NavigationStacksAnon from "./NavigationAnon";
import AuthLoadingScreen from "./AuthLoadingScreen";
import { createStackNavigator } from "react-navigation-stack";
const JornadaStack = createStackNavigator({ NavigationStacksLogged });
const JornadaAnonStack = createStackNavigator({ NavigationStacksAnon });
const NavigationStacks = createSwitchNavigator(
{
Starter: AuthLoadingScreen,
Jornada: JornadaStack,
JornadaAnon: JornadaAnonStack
},
{
order: ["Starter"]
}
);
export default createAppContainer(NavigationStacks);
AuthLoadingScreen. js
import React, { useEffect, useState } from "react";
import Loading from "../components/Loading";
import { withNavigation } from "react-navigation";
import { isLogeado } from "../utils/acces_control";
function AuthLoadingScreen(props) {
const { navigation } = props;
const [isLogged, setIsLogged] = useState(null);
useEffect(() => {
async function logeado() {
const userState = "true";
navigation.navigate(userState === "true" ? "Jornada" : "JornadaAnon");
}
logeado();
console.log("me acabo de ejecutar");
}, [isLogged]);
return <Loading />;
}
export default withNavigation(AuthLoadingScreen);