본문 바로가기
IT

[nextjs] router.beforePopState

by 내일은교양왕 2023. 9. 25.

개념

 - popstate의 이벤트를 받고

 - router가 어떠한 행동을 하기 전에 무언가 하고 싶을 때

 

문법

router.beforePopState(cb)

cb

popstate event가 왔을 때 실행 하는 함수

object로 이벤트의 state를 받는다. 

 - url: 새로운 상태를 위한 route. 보통 페이지의 이름이 됨

 - as: 브라우저에 보여질 url

 - options: router.push에서 보내주는 추가적인 옵션

 

cb가 false를 리턴하면 popstate에 대해 어떠한것도 다루지 않는다. 

 

 

https://nextjs.org/docs/pages/api-reference/functions/use-router#routerbeforepopstate

'IT' 카테고리의 다른 글

[컴퓨터 구조] cpu 작동 원리 (기본편)  (0) 2023.10.26
web > popstate  (0) 2023.09.25
CSS > inline, block, inline-block  (0) 2023.08.28
CSS Specificity  (0) 2023.08.26
CSS Inheritance  (0) 2023.08.26