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

107
Visualizações
Child Vue component data doesn't load on first page render

In my Vue app I have some child components that previously worked, ie. their respective data loaded fine inside the parent component.

I initially achieved this by adding a key to my child component, a solution that I found online as the recommended way to update data of child components dynamically.The idea is that a component will update automatically any time the key changes.

<upcoming-events :key="rerenderWidgets"/>

I am incrementing the rerenderWidgets value like so. The child data should be ready after the Promises are finished. The following code runs in the method() lifecycle hook after checking if it is the first page load.

const promisesArray = [this.loadPrivate(),this.loadPublic()]
      await Promise.all(promisesArray).then(async() => {
        await this.getCurrentParticipants().then(async(results) => {
         this.currentParticipants = results
         this.rerenderWidgets += 1
    
     })
})

This worked for a while but the child components are no longer loading their data in the Parent until after the second page visit. The renderWidgets gets incremented but somehow the data is now not updated. I don't think I changed anything that could have broken it, but obviously something has.

The child component itself has functions which get data from a module whose data should be ready once the above Promises are done, so I am not sure why it no longer works.

I also tried using the following code in the updated() hook that as it is supposed to run after the page has fully rendered. I figured all of the data should be ready when this function is called. But it doesn't work and seems to invoke a loop that shows the alert repeatedly.

 updated() {
  this.$nextTick(function () {
   alert('rerender....')
   this.rerenderWidgets += 1
  })

If anyone can tell me what might be going wrong and how I might fix it I'd much appreciate the help. Thanks in advance!

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