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

212
Views
Filtering Down Component Map using click function react

I am currently working on a fun project and I want to know how to do something that has stumped for a bit.

Basically I am using Axios to get my data and then rendering data out in a .map func then I have a click function to show only the data that is corresponding to the ID for example ID 1 has some values that I want to show in another component. How do I do that?

https://j99t7.csb.app/

If you see my sand box and click on one of the ids and see the console / code - this is where I am stuck at.

Cheers,

Dave :)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

In order to filter the data, you can use something like:

const [filteredData, setFilteredData] = useState([]);

//onclick

setFilteredData(data.filter(element => element.id === id));

//jsx return

filteredData.map(filteredElement => {
      //loop through elements and display data desired 
})
about 4 years ago · Juan Pablo Isaza Report

0

Though I'm not a React Master, onClick doesn't return JSX or TSX.

i.e where would the returned value be rendered, in most cases, it used as a void function with no return value

enter image description here

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!