업데이트 히스토리
"Switch"가 삭제되고 "Routes"가 생겼다.
"useHistory"가 삭제되고 "useNavigate"가 생겼다.
export 'Switch' (imported as 'Switch') was not found in 'react-router-dom'
<Switch />에서 <Routes /> 사용
... is not a component. All component children of must be a or <React.Fragment>
Route안에 component 대신 element 사용
Routes 자식은 Route만 사용(Routes안에 Route만 사용)
5.x버전 까지
<Switch>
<Route path="/">
<DayList />
</Route>
<Route path="/day">
<Day />
</Route>
</Switch>
6.x버전 부터
<Routes>
<Route path="/" element={<Day />} />
<Route path="/day" element={<DayList />} />
</Routes>
export 'useHistory' (imported as 'useHistory') was not found in 'react-router' (possible exports: AbortedDeferredError, Await, ...)
useHistory 대신 useNavigate 사용
5.x 버전 까지
import { useHisotry } from "react-router";
const history = useHistory();
history.push(`/home`);
6.x부터
import { useNavigate } from "react-router-dom";
const navigate = useNavigate();
navigate(`/home`);
참고