Skip to content

Commit

Permalink
Add failing SSG syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 11, 2020
1 parent 4def88c commit f7cc57d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
37 changes: 22 additions & 15 deletions test/integration/prerender/pages/blog/[post]/[comment].js
Expand Up @@ -23,20 +23,27 @@ export async function unstable_getStaticProps({ params }) {
}
}

export default ({ post, comment, time }) => {
// we're in a loading state
if (!post) {
return <p>loading...</p>
}
// Do not change this, it is making sure our SSG transform handles
// export default in this way with a class component
class Page extends React.Component {
render() {
const { post, comment, time } = this.props
// we're in a loading state
if (!post) {
return <p>loading...</p>
}

return (
<>
<p>Post: {post}</p>
<p>Comment: {comment}</p>
<span>time: {time}</span>
<Link href="/">
<a id="home">to home</a>
</Link>
</>
)
return (
<>
<p>Post: {post}</p>
<p>Comment: {comment}</p>
<span>time: {time}</span>
<Link href="/">
<a id="home">to home</a>
</Link>
</>
)
}
}

export default Page
33 changes: 21 additions & 12 deletions test/integration/prerender/pages/blog/[post]/index.js
Expand Up @@ -38,16 +38,25 @@ export async function unstable_getStaticProps({ params }) {
}
}

export default ({ post, time, params }) => {
return (
<>
<p>Post: {post}</p>
<span>time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/">
<a id="home">to home</a>
</Link>
</>
)
function Query() {
return <div id="query">{JSON.stringify(useRouter().query)}</div>
}

// Do not change this, it is making sure our SSG transform handles
// export default in this way with a class component
export default class Page extends React.Component {
render() {
const { post, time, params } = this.props
return (
<>
<p>Post: {post}</p>
<span>time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<Query />
<Link href="/">
<a id="home">to home</a>
</Link>
</>
)
}
}

0 comments on commit f7cc57d

Please sign in to comment.