Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- javascript 함수
- Spring DTO
- Spring Controller return
- Spring Entity
- springbatch chunk
- step 테이블
- Spring JPA
- Spring CORS
- react Page
- react forwardRef
- react jsx if
- Docker Windows 설치
- react link
- react Quill
- JPA Update\
- react react-router-dom v6
- editor Quill
- react quill custom
- 코드 중복제거
- Javascript
- 텍스트가 많은 경우
- springbatch
- spring security
- spring
- spring builder
- JPA Insert
- SpringBatch 스키마
- javascript 기초
- javascrpit 기초
- react
Archives
- Today
- Total
천천히 알아보는 코딩공부
[react] router Link 사용법 본문
https://daeseok94.tistory.com/45
[react] react-router-dom v6 으로 navigate 만들어보기
1. 해당 프로젝트에 react-router-dom 사용 환경 준비 yarn을 통해 설치 yarn add react-router-dom npm을 통해 설치 npm install react-router-dom BrowserRouter : React 웹 애플리케이션 개발 시 클라이언트 사이드 라우팅을
daeseok94.tistory.com
router 사용 예제는 위를 참고해주세요!!
Link 사용시 URL에 파라미터 표시
App.js
<Route path="/study_main" element={<StudyMain />}>
<Route index element={<StudyList />} />
<Route path=":studyId" element={<Study />} />
</Route>
예 ) URL localhost.com/study_main/3
Link 삽입하는 곳
<Link to={`/study_main/${study.id}`} />
Link 로 넘어간 페이지 파라미터 가져오기
const {page, id} = useParams();
예 ) URL localhost:3000/study_main/3 <-- 해당 URL 이나 새로고침 ERR_aborted 404 에러시
webpack 설정
webpack.config.js
new HtmlWebPackPlugin ({
...,
publicPath: '/'
}),
'React > 기초' 카테고리의 다른 글
[react] router props 값 이동 (0) | 2023.01.26 |
---|---|
[React] Hooks - forwardRef (0) | 2022.12.28 |
[react] jsx if문 정리 (0) | 2022.10.27 |
[React] jsx 반복문 / for 반복문 (0) | 2022.09.26 |
[React] API 연동 - axios (0) | 2022.09.26 |
Comments