-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update examples to use getStaticProps where possible (#11136)
* Remove micro example * Remove page that uses getInitialProps * Update with-docker example * Update dynamic import example * Update Fela example * Update Flow example * Update framer motion example * Remove freactal example * Remove with-higher-order-component * Remove with-immutable-redux-wrapper as it shows avenues to performance issues * Remove example that doesn't have usage * Update with-kea * Remove example that is not used * Update next-page-transitions example * Remove next-routes example as dynamic routes are supported by default * Add link to documentation * Update Overmind example * Update pretty-url-routing example * Remove update with low usage * Update with-react-ga example * Update React Helmet example * Remove mobile-detect from carousel example * Remove react-useragent as it shows a bad practice * Remove react-uwp example as it has low usage * Remove recompose example as it shows outdated practices * Remove refnux example as it has low usage * Remove example that can be created using api routes * Update with-segment-analytics * Update socket.io example * Remove socket.io example as it's shows bad practices * Update static export example * Update universal configuration example
- Loading branch information
1 parent
bfab990
commit 7e2d476
Showing
180 changed files
with
359 additions
and
4,586 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
import React from 'react' | ||
import getConfig from 'next/config' | ||
const { publicRuntimeConfig } = getConfig() | ||
|
||
const { API_URL } = publicRuntimeConfig | ||
|
||
export default class extends React.Component { | ||
static async getInitialProps() { | ||
// fetch(`${API_URL}/some-path`) | ||
return {} | ||
} | ||
|
||
render() { | ||
return <div>The API_URL is {API_URL}</div> | ||
} | ||
export default () => { | ||
return <h1>Hello World!</h1> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default () => <p>Hello World 1 (imported dynamiclly) </p> | ||
export default () => <p>Hello World 1 (imported dynamically) </p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default () => <p>Hello World 2 (imported dynamiclly) </p> | ||
export default () => <p>Hello World 2 (imported dynamically) </p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default () => <p>Hello World 3 (imported dynamiclly) </p> | ||
export default () => <p>Hello World 3 (imported dynamically) </p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default () => <p>Hello World 4 (imported dynamiclly) </p> | ||
export default () => <p>Hello World 4 (imported dynamically) </p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default () => <p>Hello World 5 (imported dynamiclly) </p> | ||
export default () => <p>Hello World 5 (imported dynamically) </p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,11 @@ | ||
import App from 'next/app' | ||
import React from 'react' | ||
import FelaProvider from '../FelaProvider' | ||
|
||
export default class MyApp extends App { | ||
static async getInitialProps({ Component, ctx }) { | ||
let pageProps = {} | ||
|
||
if (Component.getInitialProps) { | ||
pageProps = await Component.getInitialProps(ctx) | ||
} | ||
|
||
return { pageProps } | ||
} | ||
|
||
render() { | ||
const { Component, pageProps, renderer } = this.props | ||
return ( | ||
<FelaProvider renderer={renderer}> | ||
<Component {...pageProps} /> | ||
</FelaProvider> | ||
) | ||
} | ||
function MyApp({ Component, pageProps, renderer }) { | ||
return ( | ||
<FelaProvider renderer={renderer}> | ||
<Component {...pageProps} /> | ||
</FelaProvider> | ||
) | ||
} | ||
|
||
export default MyApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,30 @@ | ||
import App from 'next/app' | ||
import Link from 'next/link' | ||
import React from 'react' | ||
|
||
export default class MyApp extends App { | ||
static async getInitialProps({ Component, router, ctx }) { | ||
let pageProps = {} | ||
function MyApp({ Component, pageProps }) { | ||
return ( | ||
<> | ||
<header> | ||
<nav> | ||
<Link href="/"> | ||
<a>Home</a> | ||
</Link> | ||
| | ||
<Link href="/about"> | ||
<a>About</a> | ||
</Link> | ||
| | ||
<Link href="/contact"> | ||
<a>Contact</a> | ||
</Link> | ||
</nav> | ||
</header> | ||
|
||
if (Component.getInitialProps) { | ||
pageProps = await Component.getInitialProps(ctx) | ||
} | ||
<Component {...pageProps} /> | ||
|
||
return { pageProps } | ||
} | ||
|
||
render() { | ||
const { Component, pageProps } = this.props | ||
return ( | ||
<> | ||
<header> | ||
<nav> | ||
<Link href="/"> | ||
<a>Home</a> | ||
</Link> | ||
| | ||
<Link href="/about"> | ||
<a>About</a> | ||
</Link> | ||
| | ||
<Link href="/contact"> | ||
<a>Contact</a> | ||
</Link> | ||
</nav> | ||
</header> | ||
|
||
<Component {...pageProps} /> | ||
|
||
<footer>I`m here to stay</footer> | ||
</> | ||
) | ||
} | ||
<footer>I`m here to stay</footer> | ||
</> | ||
) | ||
} | ||
|
||
export default MyApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.