Unverified Commit 44b7b3c9 authored by David Janda's avatar David Janda Committed by GitHub

Updated with-webpack-bundle-size-analyzer to use SSG (#11657)

* Replaced getInitialProps with SSG

* Moved faker to a top level import and re-added contact.js
parent 43a8e57b
export default () => <div>About us</div> import Link from 'next/link'
import faker from 'faker'
const About = ({ name }) => {
return (
<div>
<h1>About Page</h1>
<p>Welcome, {name}.</p>
<p>
This page is using getStaticProps, so the name will always be {name}{' '}
even if you reload the page.
</p>
<div>
<Link href="/">
<a>Home Page</a>
</Link>
</div>
</div>
)
}
export async function getStaticProps() {
const name = faker.name.findName()
return {
props: {
name,
},
}
}
export default About
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import faker from 'faker'
export default class Index extends React.Component { const Index = ({ name }) => {
static getInitialProps({ req }) { return (
if (req) { <div>
// Runs only in the server <h1>Home Page</h1>
const faker = require('faker') <p>Welcome, {name}.</p>
const name = faker.name.findName() <p>
return { name } This page is using getServerSideProps, so the name will be different
} every time the page is rendered.
</p>
// Runs only in the client
return { name: 'Arunoda' }
}
render() {
const { name } = this.props
return (
<div> <div>
<h1>Home Page</h1> <Link href="/about">
<p>Welcome, {name}</p> <a>About Page</a>
<div> </Link>
<Link href="/about">
<a>About Page</a>
</Link>
</div>
</div> </div>
) </div>
)
}
export async function getServerSideProps() {
const name = faker.name.findName()
return {
props: {
name,
},
} }
} }
export default Index
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment