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

147
Visualizações
Refresh a functional component from another one

I have three files: App.js, A.js and B.js. A and B are functional components which are used in App.js. Within A.js I have a function foo(), and within this function I want to force B.js to re-render.

Any idea how to do this?

I googled this problem and found out that I could set a state in B.js and update that state. But how can I update this external state from foo() in A.js?

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

0

Have a state in your App, then pass its state to B and setState function to A as props. Then whenever, you update the state through setState function from component A, it will cause to re-render the component B. It happens becuase react trigger re-rendering whenever props update.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can rerender a component by changing the key attribute value. every time the key is changed React unmount and mount the component.

about 4 years ago · Juan Pablo Isaza Relatório

0

Why do you want to re-render it? If you pass props to a component it will automatically re-render if those props changes.

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