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'
|
2017-11-04 14:05:16 +00:00
|
|
|
|
import 'isomorphic-unfetch'
|
2016-12-22 23:05:49 +00:00
|
|
|
|
|
2018-05-13 16:12:03 +00:00
|
|
|
|
export default class Preact extends React.Component {
|
2016-12-22 23:05:49 +00:00
|
|
|
|
static async getInitialProps () {
|
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
|
const res = await fetch('https://api.github.com/repos/developit/preact')
|
|
|
|
|
const json = await res.json()
|
|
|
|
|
return { stars: json.stargazers_count }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<p>Preact has {this.props.stars} ⭐️</p>
|
2018-12-17 16:34:32 +00:00
|
|
|
|
<Link prefetch href='/'>
|
|
|
|
|
<a>I bet next has more stars (?)</a>
|
|
|
|
|
</Link>
|
2016-12-22 23:05:49 +00:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|