라우터를 위한 폴더를 위 처럼 만들어주고  improt, export해주면된다.

 

import Home from "./pages/Home";
import Diary from "./pages/Diary";
import New from "./pages/New";
import { Routes, Route } from "react-router-dom";
import Notfound from "./pages/Notfound";

const App = () => {
  //1. '/':모든일기 렌더링 home페이지

  //2. '/new' : 새로운 일기를 작성하는 New페이지
  //3. '/diary' : 일기를 상세히 조회하는 Diary 페이지
  return (
    //Routes안애는 Route만 가능.
    <>
      <div>Hello</div>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/Diary" element={<Diary />} />
        <Route path="/New" element={<New />} />
        <Route path="*" element={<Notfound />} />
      </Routes>
    </>
  );
};

export default App;

위 처럼 하면 세팅 끝

+ Recent posts