[useHistory] history 객체 이용법

JJeong·2021년 4월 1일
0

history 객체는 다음 속성과 메서드를 가집니다.

goback과 goForward는 go(-1) go(1)로 각각 나타낼 수 있으므로 생략하면 사용자를 이동시키는 메서드로 go, push, replace가 남게 된다.

When you use the router.replace, you're overwritting the top of the the stack.
When using the router.push, it adds a new route to the top of the stack.

홈 -> 게시판 -> 로그인 순으로 움직였다고 가정하자.
로그인에서 push("/게시판")을 날리면 히스토리는 홈 -> 게시판 -> 로그인 -> 게시판이 된다.
반면 replace("/게시판)을 날리면 현재 히스토리인 로그인을 날려버리고 홈 -> 게시판 -> 게시판이 된다.

0개의 댓글