라우팅이란?
페이지 이동을 의미
next 에서 hook을 제공한다.
const router = useRouter()
useRouter의 기능은 여러가지가 있는데,
그 중 하나인 router.push() 는 페이지를 이동시킨다.
const router = useRouter()
router.push("이동할 페이지")
예시
import { useRouter } from "next/router";
export default function StaticRoutingPage() {
const router = useRouter();
const onClickMove = () => {
// router.push : 페이지 이동
router.push("/이동할 페이지");
};
// 이동하기 버튼 클릭시 router.push 안에 있는 주소로 이동한다.
return <button onClick={onClickMove}>페이지 이동하기!!!</button>;
}
'비공개 > 강의 간단 정리(추후 복습하면서 수정)' 카테고리의 다른 글
[Section 05-03] static-routing-board-query (0) | 2023.05.07 |
---|---|
[Section05-02] static-routing-board (0) | 2023.05.05 |
[Section04-05] graphql-mutation-product (0) | 2023.05.05 |
[Section04-04] graphql-mutation-input (0) | 2023.05.05 |
[Section04-03] graphql-mutation-args (0) | 2023.05.05 |