1import { Route, useParams } from "react-router-dom";
2
3// Route with URL param of id
4<Route path="/:id" children={<Child />} />
5
6// We can use the `useParams` hook here to access
7// the dynamic pieces of the URL.
8let { id } = useParams();
1const Child = ({ match }) => (
2 <div>
3 <h3>ID: {match.params.id}</h3>
4 </div>
5)
1 const pathArray = window.location.pathname.split('/');
2 const id = pathArray[2];