rsnext/examples/using-router/components/Header.js
Arunoda Susiripala 141c045c68 Make next/router a client only API. (#443)
* Prevent using 'next/router' APIs inside 'getInitialProps'

* Remove incorrect documentation.

* Make next/router a client only API.
2016-12-20 09:27:43 -08:00

29 lines
445 B
JavaScript

import React from 'react'
import Router from 'next/router'
const styles = {
a: {
marginRight: 10
}
}
const Link = ({ children, href }) => (
<a
href='#'
style={styles.a}
onClick={(e) => {
e.preventDefault()
Router.push(href)
}}
>
{ children }
</a>
)
export default () => (
<div>
<Link href='/'>Home</Link>
<Link href='/about'>About</Link>
<Link href='/error'>Error</Link>
</div>
)