Last active
January 3, 2018 00:23
-
-
Save wharley/0cf78a8a18d6ef3985cc138b5f3f7340 to your computer and use it in GitHub Desktop.
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 Router from 'next/router' | |
export default () => ( | |
<div> | |
<Link href='/'>Home</Link> | |
<Link href='/about'>About</Link> | |
<Link href='/blog'>Blog</Link> | |
</div> | |
) | |
function onClickHandler (href) { | |
return (e) => { | |
e.preventDefault() | |
Router.push(href) | |
} | |
} | |
const Link = ({ children, href }) => ( | |
<a href='#' onClick={onClickHandler(href)}> | |
{children} | |
<style jsx>{` | |
a { | |
margin-right: 10px; | |
} | |
`}</style> | |
</a> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment