Created
September 25, 2021 12:19
-
-
Save dahyun31x/c3395d1b47c0867cee3741c14dda86c2 to your computer and use it in GitHub Desktop.
[Next.js] 페이지의 일부분만 라우팅하기
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRouter } from 'next/router' | |
import Link from 'next/link' | |
export default function TabsPage() { | |
const router = useRouter() | |
const tab = router.query.tab || 0 | |
return <div> | |
<ul> | |
<li><Link shallow href={{ pathname: '/tabs', query: { tab: 0 } }}>Tab 0</Link></li> | |
<li><Link shallow href={{ pathname: '/tabs', query: { tab: 1 } }}>Tab 1</Link></li> | |
<li><Link shallow href={{ pathname: '/tabs', query: { tab: 2 } }}>Tab 2</Link></li> | |
</ul> | |
<p>Selected tab: {tab}</p> | |
</div> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment