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
- CSS
- getModifierState
- createGlobalStyle
- npm styled-reset
- fetch
- next.js css
- rewrites
- API token
- 컨디셔널 렌더링
- input type=file
- bootstrap
- react env
- git lab
- github
- nextjs 설치
- nextjs .env
- ngrok설치
- SCSS
- ngrok실행
- react typescript
- react
- nextjs
- There isn’t anything to compare
- dart 변수
- github io
- typescript react
- Git
- icon
- styled components
- API 토큰
Archives
- Today
- Total
꾸준히 성장하는 개발자
[React Hook] useParams 본문
React에서 router 사용 시 parameter 정보를 가져와 활용하길 원한다면
useParams을 이용하면 된다.
useParams를 import 하기 위해서 react-router가 인스톨되어 있어야 한다.
import {useParams} from 'react-router'
Route.tsx
Route path에 parameter로 coinId를 넣어주었다.
Coin.tsx
useParams를 불러와 현재 파라미터가 무엇인지 콘솔에 찍어본다
현재 url 에서 root 경로의 뒤에 파라미터가 console에 찍히는 것을 확인할 수 있다.
'React' 카테고리의 다른 글
.env 파일을 통한 환경변수 관리하기 (0) | 2022.06.22 |
---|---|
[React] vite 사용해보기 (0) | 2022.06.13 |
[React] styled-reset _2 ( createGlobalStyle 전역 스타일로 관리 ) (0) | 2022.06.07 |
[React] styled-reset _1 (npm i styled-reset) (0) | 2022.06.07 |
[React] 컨디셔널 렌더링 ?? (0) | 2022.05.31 |