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

92
Vistas
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
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