How to use dynamic route in react router 5
Issue #658
Declare routes, use exact to match exact path as finding route is from top to bottom. For dynamic route, I find that we need to use render and pass the props manually.
Declare Router as the rooter with Header, Content and Footer. Inside Content there is the Switch, so header and footer stay the same across pages
1 | import { |
To trigger route request, use useHistory hook. Note that we need to declare variable, and not use useHistory().push directly
1 | import { useHistory } from 'react-router-dom' |
To get parameters, use match
1 | export default function BookDetail(props) { |
Updated at 2020-06-03 05:07:00