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
- react env
- nextjs
- git lab
- SCSS
- ngrok설치
- fetch
- github io
- nextjs 설치
- ngrok실행
- npm styled-reset
- There isn’t anything to compare
- CSS
- react
- github
- nextjs .env
- createGlobalStyle
- API token
- next.js css
- 컨디셔널 렌더링
- bootstrap
- input type=file
- API 토큰
- typescript react
- icon
- styled components
- rewrites
- getModifierState
- react typescript
- dart 변수
- Git
Archives
- Today
- Total
꾸준히 성장하는 개발자
react의 라우팅 본문
SPA 라우팅 과정
- 브라우저에서 최초에 '/' (root) 경로로 요청을 하면,
- React Web App 을 내려줍니다.
- 내려받은 React App 에서 '/' 경로에 맞는 컴포넌트를 보여줍니다.
- React App 에서 다른 페이지로 이동하는 동작을 수행하면,
- 새로운 경로에 맞는 컴포넌트를 보여줍니다.
Declarative routing for React apps at any scale | React Router
Version 6 of React Router is here! React Router v6 takes the best features from v3, v5, and its sister project, Reach Router, in our smallest and most powerful package yet.
reactrouter.com
react router 라이브러리 설치하는 방법
npm i react-router-dom
- cra(create-react-app) 에 기본 내장된 패키지가 아닙니다.
- react-router-dom 은 Facebook 의 공식 패키지는 아닙니다.
- 가장 대표적인 라우팅 패키지입니다.
예시로
이런 방식으로 about, home, profile 파일을 만들어 주었다.
이렇게 페이지에 표현이 되는데 Home 페이지입니다.를 ./ 경로에서만 나오게 하려면
<Route path="/" exact component={Home} />
이렇게 exact 를 중간에 작성해주면 된다. (v5에서 사용, v6에서는 사용하지 않는다 )
https://slides.com/woongjae/react2021#/21/7 패스트캠퍼스 수강 중
공부 내용 정리 중
React 2021
리액트 2021
slides.com
'React' 카테고리의 다른 글
[react] styled-component 정리하기 (1) | 2022.02.08 |
---|---|
React-Router-Dom v6 되며 바뀐 점 정리 (1) | 2022.01.24 |
husky , lint-staged (0) | 2022.01.23 |
Prettier (0) | 2022.01.22 |
ESLint (0) | 2022.01.22 |