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

101
Views
passing parameter to another component using Link in react

I know if I need to call another component then we need to pass like <A x={y}/> and we can access props.x inside A.

But here I need to call EditCertificate so I need to pass id to EditCertificate. but I am using Link here. I am not able to pass the id. when I am accesssing it, it is coming undefined.

<Link to={`/${props.certificate.id}/edit` }  >Edit</Link>

and I am calling this page like below.

<Route path ="/:id/edit" component={EditCertificate} ></Route>

how can I access :id inside the EditCertificate .when I am accessing it is giving undefined. do I need to pass some other properties.

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

0

since you're using react-router you can simply import useParams hook and get the id in you EditCertificate component

import { useParams } from 'react-router-dom'; 


const { id } = useParams(); // add inside your component body
about 4 years ago · Juan Pablo Isaza Report

0

Since EditCertificate is rendered directly by the route:

<Route path ="/:id/edit" component={EditCertificate} />

the route props are passed to EditCertificate. You just need to access them from props.

const { id } = props.match.params;

if EditCertificate is a class component, then obviously access from this.props.

const { id } = this.props.match.params;
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!