티스토리 뷰
window.location 을 이용해서 페이지이동으로 하려고하니 전체 페이지가 refresh되면서 recoil의 state가 날아가는 현상이 발생
next/router를 이용해서 계속 에러가 발생했는데 next/navigation 의 useRouter를 사용했어야했다.
import { useRouter } from 'next/navigation';
export default function Page() {
const router = useRouter();
return (
<button type="button" onClick={() => router.push('/dashboard')}>
Dashboard
</button>
);
}
Reference
https://beta.nextjs.org/docs/api-reference/use-router
Client Component Hooks: useRouter | Next.js
API reference for the useRouter hook.
beta.nextjs.org
'React.js' 카테고리의 다른 글
tailwind css사용시 input에 outline border가 사라지지 않을 경우 (0) | 2023.01.10 |
---|---|
마우스클릭이벤트 click과 mousedown의 차이점 (0) | 2023.01.06 |
input data 를 관리하는 3가지 방법 (0) | 2022.11.23 |
How to manage state with useState hook (0) | 2022.03.03 |
Intro to React.js (0) | 2019.08.29 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- string class in java
- 알고리즘
- 프로그래머스 알고리즘
- code refactoring
- hackerrank solution
- equals()
- spring boot application
- math.max
- algorithm
- Collection Framework
- math.abs
- hackerrank
- HackerRank Algorithm
- substring()
- rest parameter
- compareTo()
- easy algorithm
- hackerrank javascript solution
- easy javascript algorithm
- C++
- javascript
- Javascript Algorithm
- 프로그래머스 알고리즘문제
- HashMap
- hackerrank javascript
- ... in Javascript
- java
- repeat()
- 프로그래머스
- Object type casting
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함