skip to Main Content

Javascript – Targeting Data in a .map with onClick

So I have the following code: const test = (e) => { console.log('example:', e.target.item.attributes.dataIWant); } {records.map((item, index) => { return ( <> <Accordion key={index}> <AccordionSummary onClick={test(item)} expandIcon={<ExpandMoreIcon />} aria-controls="panel1a-content" id="panel1a-header"> <Typography>{item.attributes.name} {item.attributes.date}</Typography> </AccordionSummary> </Accordion> </> ) })} This is using…

VIEW QUESTION
Back To Top
Search