파일 이름을
...앞의 경로/completed/[userChallengId].tsx
이렇게 해서 동적라우팅을 구현했었다.
const router = useRouter();
const asPath = router.asPath;
const pathname = router.pathname;
console.log(asPath);
console.log(pathname);
그러면 아래와 같이 출력된다.
...앞의 경로/completed/651627fb3931e74294dda3ca
...앞의 경로/completed/[userChallengId]
완전 정확한 url을 확인하려면 asPath를 써야한다.
'Front-End' 카테고리의 다른 글
[Vercel, Front-end] mono-repo에서 배포 안되는 문제 해결 (1) | 2023.11.27 |
---|---|
[Styled-components] it looks like an unknown prop "X" is being sent through to the DOM 오류 해결 (X: 사용자 정의) (0) | 2023.10.12 |
[Next] Next내에서 .env 파일의 환경변수들이 안 읽히는 문제 해결 (0) | 2023.09.25 |
[Node] npm 명령어들 링크 모음 (0) | 2023.09.21 |
[Front-End] Carousel (0) | 2023.09.19 |