My react router works fine.. but I would like get the date from the Path
as the title
which expects a string.
<Route exact path="/meeting/:date"
breadcrumb="Meetings"
title={DATE}
component={(props) => (
<FooComponent
date={props.match.params.date} />
)}
/>
thanks
To get path params in React Router, we can use the useParams hook. We create the Child component that calls the useParams hook to return an object with the route params in the URL. And we render the value of the id param on the page.
There is a new api in react-router-dom 5.1
https://github.com/ReactTraining/react-router/releases/tag/v5.1.0
import {useParams} from "react-router-dom";
function MyComponent(){
const {date} = useParams()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With