Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!