'How to get URL params in React by using useParams()
I have implemented react-router-dom for routing purpose. I want to use useParams() in my component.
Here is My Code
// routing
import { Switch, Route } from 'react-router-dom';
import Mypage from '../components/Mypage/Loadable
<Switch>
<Route path="/ok/:id">
<Mypage/>
</Route>
<Switch>
MyPage.js
import { Link, useParams } from 'react-router-dom';
let {id} = useParams(); // ===> This says **Object(...) is not a function**
return ( <p> id : {id} </p>)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
