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

101
Visualizações
call api and render data after states get updated

In use effect I am checking current role of user, if it is admin setAdmin(true) set the state of admin. The default admin state is false. When component gets rendered, it gets rendered with admin as false and state gets updated in sometime. I want to call api and render data after state gets updated.

useEffect(async () => {
    //Authenticates User through their email
    let firebaseId;
    const user = await firebase.auth().currentUser;
    if (user) {
      let getUserProfile = async () => {
        let loggedInUser = await axios.get(
          `${config.API_URL}/data/profile/${user.uid}`
        );
        if (loggedInUser.data.role == "admin") {
          setAdmin(true);
        }
      };
      getUserProfile();
    }
}, []);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use useEffect hook in above case.

Ex:

useEffect(() => {
   // Call your API
}, [admin]);

Above hook will call when admin state updated.

about 4 years ago · Juan Pablo Isaza Relatório
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