Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Whats the best way to re render the subcomponent inside the router after the parent component has re rendered

So I have a component rendering the routes and before that in the useEffect I am calling the isLoggedIn Api before setting the react context.

useEffect(() => {
    async function performAuthRedirection() {
        const data = await isLoggedIn();
        if (data.userSignedIn) {
            setAuthState(data.userData);
            return navigate(location.pathname);
        }
        if (!data.userSignedIn || authState._id === '') {
            navigate('/signIn');
        }
    }
    performAuthRedirection();
}, []);

return <Routes>
            <Route
                path="/"
                element={
                    <HomePage
                        authState={authState}
                    />
                }
            />
        </Routes>

In home page I need to call another api that gives me access denied if I am not signed in. Now since the homepage(child component of above component renders first) this above component renders last(even though I am updating the react.context) and thats why I always see access denied. What can I do to re render the homepage such that it renders again.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda