Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda