Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update custom-server-express example with getServerSideProps #11035

Merged
merged 8 commits into from Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/custom-server-express/package.json
Expand Up @@ -10,7 +10,7 @@
"cross-env": "^5.2.0",
"express": "^4.14.0",
"next": "latest",
"react": "^16.7.0",
"react-dom": "^16.7.0"
"react": "^16.13.0",
"react-dom": "^16.13.0"
}
}
30 changes: 14 additions & 16 deletions examples/custom-server-express/pages/posts.js
@@ -1,19 +1,17 @@
import React, { Component } from 'react'
import React from 'react'

export default class extends Component {
static getInitialProps({ query: { id } }) {
return { postId: id }
}
export default function(props) {
return (
<div>
<h1>My {props.id} blog post</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
)
}

render() {
return (
<div>
<h1>My blog post #{this.props.postId}</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
)
}
export async function getServerSideProps({ query: { id } }) {
lfades marked this conversation as resolved.
Show resolved Hide resolved
return { props: { id } }
}