React Router
2023/9/24 14:47:00
useParam(副作用)のモックを作るのが面倒なので、単体テストしづらいんじゃとなった
import { ReactNode } from "react";
import { useParams } from "react-router-dom";
export function RouteSolver({Component, args}:{Component:(props:any)=>ReactNode, args:any}) {
const params = useParams()
return <>{Component({...params, ...args})}</>
}
<Routes>
<Route path="/:kno" Component={()=><RouteSolver Component={KnoToPost} args={{}} />} />
</Routes>