mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
f6ece560e4
* Added data fetch example * Finished updating examples install instructions and added data-fetch example to main readme
23 lines
545 B
JavaScript
23 lines
545 B
JavaScript
|
||
import React from 'react'
|
||
import Link from 'next/prefetch'
|
||
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>
|
||
<Link href='/preact'>How about preact?</Link>
|
||
</div>
|
||
)
|
||
}
|
||
}
|