Last active
June 11, 2017 13:11
-
-
Save quentin-sommer/7e8fc8aa69c798ad25130ed0e5809eb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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