Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda