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

83
Views
no puedo encontrar la matriz correspondiente de búsqueda de objetos por id

Usé un enlace personalizado y quiero mostrar un solo elemento que coincida con una identificación particular, probé varios métodos pero no funcionó. Este es mi código:

const SingleServiceDetail = () => {

 const {idOfService} = useParams(); const [data] = useCustom(); const singleItem = data.find(element =>element._id === idOfService); console.log(singleItem); return ( <div> <h2>You have Choosed :{idOfService}</h2> {/* <p>{singleItem.name}</p> */} </div> );

};

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

0

Posiblemente idOfService de useParams es una cadena y element._id es un número.

Pruebe con doble igual, escribirá coaccionar y verificará la identificación.

 const singleItem = data.find(element => element._id == idOfService);

de lo contrario, cambie el idOfService a número

 const singleItem = data.find(element => element._id === +idOfService);
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!