import { BrowserRouter, Link, Route, Switch } from 'react-router-dom';
import Home from './components/home';
import Detail from './components/profile';
function App() {
return (
<BrowserRouter>
<Switch>
{/* <Route path={"/home"} exact component={Home} /> */}
<Route path={"/home"} exact>
<Home />
</Route>
<Route path="/Detail">
<Detail />
</Route>
</Switch>
</BrowserRouter>
);
}
export default App;
import { BrowserRouter, Link, Route, Routes } from 'react-router-dom';
import Home from './components/home';
import Detail from './components/profile';
function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/home" exact element={<Home />} />
<Route path="/detail" exact element={<Detail />} />
</Routes>
</BrowserRouter>
);
}
export default App;
import { useHistory } from 'react-router-dom'
...
const history = useHistory();
...
history.push('/detail')
...
import { useNavigate } from 'react-router-dom'
...
const navigate = useNavigate();
...
navigate('/detail')
...
느낀점 : 좀 더 간편해진거 같긴한데 왜 바꿧는지 모르겠다. 알아봐야지~