Skip to content

Instantly share code, notes, and snippets.

@quentin-sommer
Last active June 11, 2017 13:11
Show Gist options
  • Save quentin-sommer/7e8fc8aa69c798ad25130ed0e5809eb0 to your computer and use it in GitHub Desktop.
Save quentin-sommer/7e8fc8aa69c798ad25130ed0e5809eb0 to your computer and use it in GitHub Desktop.
const PageWrapper = Comp => (
class extends React.Component {
static async getInitialProps(args) {
return {
ua: args.req ? args.req.headers['user-agent'] : navigator.userAgent,
lang args.req.query.language,
foo: 'bar',
/* and so on.. */
...(Comp.getInitialProps ? await Comp.getInitialProps(args) : null),
}
}
render() {
return (
<Comp {...props} />
)
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment