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

160
Views
Estado del mapa en reactjs

Estoy tratando de mapear también funciones del objeto.

 const KindOfShoots = [ { id: 1, name: "Shoot in Studio", link: "/Photoshoot",icon:"fa fa-calendar", onClickAction: "setToggle1" }, { id: 2, name: "Shoot at other Location", link: "/Photoshoot" ,icon:"fa fa-calendar", onClickAction: "setToggle2" },];

fragmentos a continuación:

 { KindOfShoots.map((type)=>( <KindOfShootLayout > <div className="KindOfShootLayout" onClick={() => {type.onClickAction}((t) => !t) }> {type.name} <i className={type.icon}></i> </div> </KindOfShootLayout> )) }

Necesito cambiar los estados toggle1 & toggle2 y también almacenar los estados y pasarlos a otro componente, estoy un poco bloqueado

 const [toggle1, setToggle1] = useState(true); const [toggle2, setToggle2] = useState(true);
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

const KindOfShoots = [ { id: 1, name: "Shoot in Studio", link: "/Photoshoot",icon:"fa fa-calendar", onClickAction: setToggle1 }, { id: 2, name: "Shoot at other Location", link: "/Photoshoot" ,icon:"fa fa-calendar", onClickAction: setToggle2 },]; { KindOfShoots.map((type)=>( <KindOfShootLayout > <div className="KindOfShootLayout" onClick={() => type.onClickAction(!toogle)}> {type.name} <i className={type.icon}></i> </div> </KindOfShootLayout> )) }
about 4 years ago · Juan Pablo Isaza Report

0

Ok, creo que encontré una respuesta; Usé la propiedad onToggle

 const KindOfShoots = [ { id: 1, name: "Shoot in Studio", link: "/Photoshoot", icon: "fa fa-calendar", onToggle: setToggle1, toggle: toggle1, }, { id: 2, name: "Shoot at other Location", onToggle: setToggle2, toggle: toggle2, link: "/Photoshoot", icon: "fa fa-calendar", },

];

y vuelve

 {KindOfShoots.map((type) => ( <KindOfShootLayout> <div style={{display: toggleActual}} className="KindOfShootLayout" onClick={() => type.onToggle(!type.toggle)} > {type.name} <i className={type.icon}></i> </div> </KindOfShootLayout> ))} <div style={{ display: toggle1 ? "none" : "block" }}> <ThirdGrandchild /> </div> <div style={{ display: toggle2 ? "none" : "block" }}> <SecondGrandchild /> </div>
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!