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

167
Views
infinite rerender material ui accordian

I'm getting an infinite rerender when I try to make a controlled accordian component using the material ui accordian. Here is my code, anybody have any ideas why it might be causing an infinite rerender?

  const [expanded, setExpanded] = React.useState([true, false, false]);

  const handleChange = idx => {
    const newState = expanded.map((value, i) => (i === idx ? !value : value));
    setExpanded(newState);
  };

And then the expanded and onChange props on the Accordian component are written as so:

<Accordion expanded={expanded[0]} onChange={handleChange(0)}>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You don't need an array to do it.

Add a unique id to each Accordion like this

<Accordion expanded={expanded === "first"} onChange={setExpanded("first")} />
about 4 years ago · Juan Pablo Isaza Report
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!