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 }) {
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 ( return (
<div> <div>
<h1>Home Page</h1> <h1>Home Page</h1>
<p>Welcome, {name}</p> <p>Welcome, {name}.</p>
<p>
This page is using getServerSideProps, so the name will be different
every time the page is rendered.
</p>
<div> <div>
<Link href="/about"> <Link href="/about">
<a>About Page</a> <a>About Page</a>
...@@ -27,5 +17,15 @@ export default class Index extends React.Component { ...@@ -27,5 +17,15 @@ export default class Index extends React.Component {
</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