xxxxxxxxxx
import { Route, useParams } from "react-router-dom";
// Route with URL param of id
<Route path="/:id" children={<Child />} />
// We can use the `useParams` hook here to access
// the dynamic pieces of the URL.
let { id } = useParams();
import { useLocation } from 'react-router-dom';
//url = http://localhost:3000/main/ride?params=1
const location = useLocation();
const [value, setValue] = useState( new URLSearchParams(location.search).get('params'));
console.log(value) // 1
xxxxxxxxxx
<Link to={{
pathname: '/tylermcginnis',
state: {
fromNotifications: true
}
}}>Tyler McGinnis</Link>
xxxxxxxxxx
const Child = ({ match }) => (
<div>
<h3>ID: {match.params.id}</h3>
</div>
)