백엔드-리액트

리액트 시작하기

강사: 한개발 · 작성자: 이종춘 · 작성일: 2026-07-08 12:05:30 · 조회수: 22

리엑트 작업순서 1
목록으로
■ React Router 설치

패키지 사이트:
npm

검색:
react-router-dom

설치 명령어:
npm i react-router-dom

------------------------------------------------

■ HashRouter 사용

주소 형태:

http://localhost:5173/#/
http://localhost:5173/#/sub01
http://localhost:5173/#/sub02
http://localhost:5173/#/sub03

------------------------------------------------

■ 기본 구조

import { HashRouter, Routes, Route } from "react-router-dom";

<HashRouter>
<Routes>
<Route path="/" element={<Main />} />
<Route path="/sub01" element={<Sub01 />} />
<Route path="/sub02" element={<Sub02 />} />
<Route path="/sub03" element={<Sub03 />} />

{/* 잘못된 경로 */}
<Route path="*" element={<NotFound />} />
</Routes>
</HashRouter>

------------------------------------------------

■ 잘못된 경로 이동 시 에러 페이지

<Route path="*" element={<NotFound />} />

* 는 위에 등록되지 않은 모든 경로를 의미한다.

■ react-hook-form 설치

검색:
react-hook-form

설치 명령어:
npm i react-hook-form
#리엑트 작업순서 1

첨부 파일

0개
첨부된 파일이 없습니다.

댓글 / 답글

0개
댓글을 작성하려면 로그인하세요.
아직 댓글이 없습니다.