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

119
Visualizações
ReactJS, Need one component to wait on the work done in another component to begin rendering

So I have 3 components that are supposed to render inside a holder component. The 3rd component relies on the work done in the 2nd component, and the 2nd component relies on the work done in the 1st component. They both asynchronously read and write from a firebase firestore database, which obviously presents a problem. I'm getting issues because the 2nd component tries to access something from the database which doesn't exist yet, because the first component adds it.

This is how I have the components set up:

<React.Fragment>
  <div className="flex">
    <GroupPreferences />
    <SetupDatabase gId={groupID} />
    <Restaurants gId={groupID} user={user} history={history} />
  </div>
</React.Fragment>

The work done on the components relies on hooks, where the first component uses UseEffect() and the other two use ComponentDidMount(). I need to somehow wait for all the database work in GroupPreferences to finish before SetupDatabase begins rendering.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should pass callback functions to each child component, when logic inside will be done, they should trigger that callback, so you will know that the child component is done.

If you just need to understand if components have been rendered, you can use React.ref. if Ref.current have value, components are on the screen, if ref.current doesn't have value, it's haven't rendered yet

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