diff --git a/examples/with-zeit-fetch/pages/index.js b/examples/with-zeit-fetch/pages/index.js index 45154170f08a9..3a0f26b58229a 100644 --- a/examples/with-zeit-fetch/pages/index.js +++ b/examples/with-zeit-fetch/pages/index.js @@ -2,10 +2,10 @@ import React from 'react' import Link from 'next/link' import fetch from '../fetch' -function Index(props) { +export default function Index({ stars }) { return (
-

Next.js has {props.stars} ⭐️

+

Next.js has {stars} ⭐️

How about preact? @@ -13,10 +13,10 @@ function Index(props) { ) } -Index.getInitialProps = async () => { +export async function getStaticProps() { const res = await fetch('https://api.github.com/repos/zeit/next.js') const json = await res.json() // better use it inside try .. catch - return { stars: json.stargazers_count } + return { + props: { stars: json.stargazers_count }, + } } - -export default Index diff --git a/examples/with-zeit-fetch/pages/preact.js b/examples/with-zeit-fetch/pages/preact.js index e89e8a23257e1..80c2ff9b94cec 100644 --- a/examples/with-zeit-fetch/pages/preact.js +++ b/examples/with-zeit-fetch/pages/preact.js @@ -2,10 +2,10 @@ import React from 'react' import Link from 'next/link' import fetch from '../fetch' -function Preact(props) { +export default function Preact({ stars }) { return (
-

Preact has {props.stars} ⭐

+

Preact has {stars} ⭐

I bet Next.js has more stars (?) @@ -13,10 +13,10 @@ function Preact(props) { ) } -Preact.getInitialProps = async () => { +export async function getStaticProps() { const res = await fetch('https://api.github.com/repos/developit/preact') const json = await res.json() // better use it inside try .. catch - return { stars: json.stargazers_count } + return { + props: { stars: json.stargazers_count }, + } } - -export default Preact