2016-12-22 23:05:49 +00:00
|
|
|
|
|
|
|
|
|
import React from 'react'
|
2017-02-25 14:54:42 +00:00
|
|
|
|
import Link from 'next/link'
|
2016-12-22 23:05:49 +00:00
|
|
|
|
import 'isomorphic-fetch'
|
|
|
|
|
|
|
|
|
|
export default class MyPage extends React.Component {
|
|
|
|
|
static async getInitialProps () {
|
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
|
const res = await fetch('https://api.github.com/repos/zeit/next.js')
|
|
|
|
|
const json = await res.json()
|
|
|
|
|
return { stars: json.stargazers_count }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<p>Next.js has {this.props.stars} ⭐️</p>
|
2017-02-25 14:54:42 +00:00
|
|
|
|
<Link prefetch href='/preact'><a>How about preact?</a></Link>
|
2016-12-22 23:05:49 +00:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|