为了路由目的,我已经实现了 react-router-dom。我想在我的组件中使用 useParams()
。
这是我的代码
// 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>)