react-router-dom get id from route with custom components and extra path

react-router-dom provides some handy hooks. In your case, I’d suggest useParams() (link to docs)

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

function MyComponent {
  let { id } = useParams();

  return (<p>{id}</p>);
}

I’d also probably opt for not using withRouter if you will be using the hooks provided by React Router

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)