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

98
Views
How do I use setstate on multiple and one wont affect the other?

I am creating Accodion which will have multiple items with TITLE and BODY.

When a title is clicked, I want the setShow to true. But when Item A is true, I don't want item B to be true at same time. I will be fetching those data from the Server and I don't know how my items i will have in the future.

const Accordion = ({ title, text }) => {
  const [show, setShow] = React.useState(false);
  return (
    <>
      <div className="accordion-wrapper">
        <div
          onClick={() => setShow(!show)}
          className="accordion-title cursor-pointer flex flex-row flex-1 justify-between items-center"
        >
          <div className="title-text">
            <h2>{title}</h2>
          </div>
          <div className="title-icon"></div>
        </div>
        <div className="accordion-content">{text}</div>
      </div>
    </>
  );
};

export default Accordion;
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!