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

162
Visualizações
Render problem when lifting state up in React

After reading the documentation and good practices. I decided to lift up the state in my code for a specific page. When I do this, I cause my app to be laggy because now every time I am updating a specific field in a form, it triggers to re-render every others forms field along with other widgets.

I tried to use, memo on each of my components but apparently it has no effect and the re-render is triggered each time.

The problem is that the component in the picture is very 6 levels down compared to where I am declaring and updating the state. So, when I want to update the value of this specific component, bassically, it setState my whole page. A example of one of my component

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

0

useEffect hook without dependency, will continue to render your component again and again, So if you want to render your component once use useEffect with empty array as dependency like this -

useEffect(()=>{
  //code will run once after rendering
},[]);

and if you want to re-render a component base on some condition then you can use useEffect with the dependency, if that dependency value is change it will trigger the component to re-render. For eg:-

const [dependency,setDependency] = useState();

useEffect(()=>{
  //when value of dependency will change, code will run and trigge render
},[dependency]) 
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