Skip to content

Instantly share code, notes, and snippets.

@wharley
Last active January 3, 2018 00:23
Show Gist options
  • Save wharley/0cf78a8a18d6ef3985cc138b5f3f7340 to your computer and use it in GitHub Desktop.
Save wharley/0cf78a8a18d6ef3985cc138b5f3f7340 to your computer and use it in GitHub Desktop.
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