Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

942
Vistas
this.props.match.params.id in React.js is undefined

I want to get the id from the URL therefore I can use this id to get and output the user info but I can't get id from URL. I've seen useParams() but I think it is not applicable with class component. May I know if there is an alternative solution for this?

 async componentDidMount(){
    const stud_id = this.props.match.params.id;
    console.log(stud_id);
 }

see error message from console here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you're using

<Route path="/blah" component={()=><YourComponent someProp={someProp}>}/>

I mean, with arrow function as it child component, you have to pass the pros of the father (Route) to the child (YourComponent) like that:

<Route path="/blah" component={({match})=><YourComponent match={match} someProp={someProp}>}/>

Because you're creating a new "generation" so you have to pass the props by your self

about 4 years ago · Juan Pablo Isaza Denunciar

0

The most common way of reading URL params in React is using React Router. In React Router, you get URL params with this.props.match.params like you are trying to, but you have to call your component inside a Route, like for example:

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

instead of just

<YourComponent />

So that your component receives the match prop and can access this.props.match.params.id

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda