Commit 483cd105 authored by Henrik Wenz's avatar Henrik Wenz Committed by Joe Haddad

Refactor data-fetch example (#8490)

* Remove eslint exclusion

https://www.npmjs.com/package/isomorphic-unfetch

* Fix emoji char

* Update preact.js
parent 64e8c61d
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import 'isomorphic-unfetch' import fetch from 'isomorphic-unfetch'
export default class Index extends React.Component { export default class Index extends React.Component {
static async getInitialProps () { static async getInitialProps () {
// eslint-disable-next-line no-undef
const res = await fetch('https://api.github.com/repos/zeit/next.js') const res = await fetch('https://api.github.com/repos/zeit/next.js')
const json = await res.json() const json = await res.json()
return { stars: json.stargazers_count } return { stars: json.stargazers_count }
......
import React from 'react' import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import 'isomorphic-unfetch' import fetch from 'isomorphic-unfetch'
export default class Preact extends React.Component { export default class Preact extends React.Component {
static async getInitialProps () { static async getInitialProps () {
// eslint-disable-next-line no-undef
const res = await fetch('https://api.github.com/repos/developit/preact') const res = await fetch('https://api.github.com/repos/developit/preact')
const json = await res.json() const json = await res.json()
return { stars: json.stargazers_count } return { stars: json.stargazers_count }
...@@ -13,9 +12,9 @@ export default class Preact extends React.Component { ...@@ -13,9 +12,9 @@ export default class Preact extends React.Component {
render () { render () {
return ( return (
<div> <div>
<p>Preact has {this.props.stars} ⭝︝</p> <p>Preact has {this.props.stars} ⭐</p>
<Link href='/'> <Link href='/'>
<a>I bet next has more stars (?)</a> <a>I bet Next.js has more stars (?)</a>
</Link> </Link>
</div> </div>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment