Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated analyze-bundles example (#11031)
* Updated analyze-bundles example * Updated react and react-dom (for hooks)
- Loading branch information
1 parent
f75c37f
commit f78c36f
Showing
2 changed files
with
23 additions
and
26 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 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,31 +1,28 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
import faker from 'faker' | ||
|
||
export default class Index extends React.Component { | ||
static getInitialProps({ req }) { | ||
if (req) { | ||
// Runs only in the server | ||
const faker = require('faker') | ||
const name = faker.name.findName() | ||
return { name } | ||
} | ||
|
||
// Runs only in the client | ||
return { name: 'Arunoda' } | ||
} | ||
|
||
render() { | ||
const { name } = this.props | ||
return ( | ||
const Index = ({ name }) => { | ||
return ( | ||
<div> | ||
<h1>Home Page</h1> | ||
<p>Welcome, {name}</p> | ||
<div> | ||
<h1>Home Page</h1> | ||
<p>Welcome, {name}</p> | ||
<div> | ||
<Link href="/about"> | ||
<a>About Page</a> | ||
</Link> | ||
</div> | ||
<Link href="/about"> | ||
<a>About Page</a> | ||
</Link> | ||
</div> | ||
) | ||
</div> | ||
) | ||
} | ||
|
||
export default Index | ||
|
||
export async function getStaticProps() { | ||
// The name will be generated at build time only | ||
const name = faker.name.findName() | ||
|
||
return { | ||
props: { name }, | ||
} | ||
} |