mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
32 lines
582 B
JavaScript
32 lines
582 B
JavaScript
import Router from 'next/router'
|
|
|
|
export default () => (
|
|
<div>
|
|
<Link href='/'><a>Home</a></Link>
|
|
<Link href='/about'><a>About</a></Link>
|
|
<Link href='/error'><a>Error</a></Link>
|
|
</div>
|
|
)
|
|
|
|
// typically you want to use `next/link` for this usecase
|
|
// but this example shows how you can also access the router
|
|
// and use it manually
|
|
const Link = ({ children, href }) => (
|
|
<a
|
|
href='#'
|
|
style={styles.a}
|
|
onClick={(e) => {
|
|
e.preventDefault()
|
|
Router.push(href)
|
|
}}
|
|
>
|
|
{ children }
|
|
</a>
|
|
)
|
|
|
|
const styles = {
|
|
a: {
|
|
marginRight: 10
|
|
}
|
|
}
|