티스토리 뷰
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
'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
- C++
- 알고리즘
- hackerrank javascript solution
- string class in java
- repeat()
- Object type casting
- compareTo()
- spring boot application
- hackerrank
- math.max
- Collection Framework
- java
- 프로그래머스
- 프로그래머스 알고리즘문제
- math.abs
- HackerRank Algorithm
- HashMap
- javascript
- substring()
- Javascript Algorithm
- hackerrank solution
- equals()
- hackerrank javascript
- algorithm
- 프로그래머스 알고리즘
- easy algorithm
- easy javascript algorithm
- code refactoring
- rest parameter
- ... in Javascript
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함