forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor with-loading example (vercel#8560)
* Remove inline styles in favor of styled-jsx * Remove getInitialProps from app Allow automatic static optimization * Remove _document.js We really don’t need it in this example * Migrate Class to Function Components
- Loading branch information
Showing
5 changed files
with
37 additions
and
71 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
|
||
export default class About extends Component { | ||
// Add some delay | ||
static async getInitialProps () { | ||
await new Promise(resolve => { | ||
setTimeout(resolve, 500) | ||
}) | ||
return {} | ||
} | ||
const AboutPage = () => <p>This is about Next.js!</p> | ||
|
||
render () { | ||
return <p>This is about Next!</p> | ||
} | ||
AboutPage.getInitialProps = async () => { | ||
await new Promise(resolve => { | ||
setTimeout(resolve, 500) | ||
}) | ||
return {} | ||
} | ||
|
||
export default AboutPage |
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,15 +1,12 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
|
||
export default class Forever extends Component { | ||
// Add some delay | ||
static async getInitialProps () { | ||
await new Promise(resolve => { | ||
setTimeout(resolve, 3000) | ||
}) | ||
return {} | ||
} | ||
const ForeverPage = () => <p>This page was rendered for a while!</p> | ||
|
||
render () { | ||
return <p>This page was rendered for a while!</p> | ||
} | ||
ForeverPage.getInitialProps = async () => { | ||
await new Promise(resolve => { | ||
setTimeout(resolve, 3000) | ||
}) | ||
return {} | ||
} | ||
|
||
export default ForeverPage |
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,3 +1,5 @@ | ||
import React from 'react' | ||
|
||
export default () => <p>Hello Next!</p> | ||
const IndexPage = () => <p>Hello Next.js!</p> | ||
|
||
export default IndexPage |