Skip to content

Commit

Permalink
Updated analyze-bundles example (vercel#11031)
Browse files Browse the repository at this point in the history
* Updated analyze-bundles example

* Updated react and react-dom (for hooks)
  • Loading branch information
akhila-ariyachandra authored and ScriptedAlchemy committed Mar 17, 2020
1 parent 278364b commit 33273b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
4 changes: 2 additions & 2 deletions examples/analyze-bundles/package.json
Expand Up @@ -12,8 +12,8 @@
"cross-env": "^6.0.3",
"faker": "^4.1.0",
"next": "latest",
"react": "^16.7.0",
"react-dom": "^16.7.0"
"react": "^16.8.0",
"react-dom": "^16.8.0"
},
"license": "ISC"
}
45 changes: 21 additions & 24 deletions examples/analyze-bundles/pages/index.js
@@ -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 },
}
}

0 comments on commit 33273b2

Please sign in to comment.