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

151
Visualizações
how to rerender only child component?

i have problem with rerender component. I have array of object and I display it as list of tiles. Then I can check some of them and do something with picked objects. I created simple state in parent component to update selected items.

  const [selectedTable, setSelectedTable] = useState([]);

  const handleSelectTable = (state, item) => {
   if (state) {
     setSelectedTable((prev) => [...prev, item]);
   } else {
     setSelectedTable((prev) => prev.filter((el) => el !== item));
}

};

After that I pass handleSelectTable to my child component (it is single tile) and then there I have anotehr state to update if single tile is checked or not and I change that state on onClick.

 const [isChecked, setIsChecked] = useState(false);
 //-------------------------------//
 onClick={() => setIsChecked(!isChecked)}

Finaly I created useEffect that call handleSelectTable every time when state isChecked changed.

useEffect(() => {
 handleSelect(isChecked, data);
}, [isChecked]);

But unfortunately it's call infinity loop. Tahats happend becouse satate selectedTable rerender parent component with children components. Then state isChecked back to default. Is any chance to rerender only that component i want insted of rerenering parent component with all children?

Thanks for your attention.

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