Skip to content

Instantly share code, notes, and snippets.

@quentin-sommer
Created June 11, 2017 08:41
Show Gist options
  • Save quentin-sommer/0ea73a8769fe40c666faa58850cd0fb3 to your computer and use it in GitHub Desktop.
Save quentin-sommer/0ea73a8769fe40c666faa58850cd0fb3 to your computer and use it in GitHub Desktop.
class Page extends React.Component {
static async getInitialProps(args) {
return {
ua: args.req ? args.req.headers['user-agent'] : navigator.userAgent,
}
}
render() {
const {ua} = this.props
return (
<UserAgentProvider ua={ua}>
{/* Rest of Page */}
</UserAgentProvider>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment