Switch 는 여러 Route 중 순서대로 먼저 맞는 하나만 보여준다.
exact 를 뺄 수 있는 로직을 만들 수 있다.
가장 마지막에 어디 path 에도 맞지 않으면 보여지는 Component 를 설정해서, Not Found 페이지를
만들 수 있다.
Route 를 Switch 로 감싸준다.
function App() {
return (
<BrowserRouter>
<Switch>
<Route path="/profile/:id" component={Profile} />
<Route path="/profile" component={Profile} />
<Route path="/About" component={About} />
{/* 마지막은 exact 넣어주지 않으면 모든 url 은 / 를 포함하기 home 으로 들어가버린다. */}
<Route path="/" exact component={Home} />
<Route component={NotFound}></Route>
</Switch>
</BrowserRouter>
);
}