Commit a0d85d8b authored by myxvisual's avatar myxvisual Committed by Tim Neutkens

fix: Update react-uwp example support Next 3 (#2464)

* fix: Update react-uwp example support Next 3

* style: Update linted codes
parent 874f9a78
......@@ -3,11 +3,11 @@ import PropTypes from 'prop-types'
import Document, { Head, Main, NextScript } from 'next/document'
export default class MyDocument extends Document {
static async getInitialProps ({ req }) {
return req
? { userAgent: req.headers['user-agent'] }
: { userAgent: navigator.userAgent }
static getInitialProps ({ renderPage }) {
const {html, head, errorHtml, chunks} = renderPage()
return { html, head, errorHtml, chunks }
}
static contextTypes = { theme: PropTypes.object };
render () {
......
......@@ -12,7 +12,7 @@ import {
} from 'react-uwp'
class Index extends Component {
static getInitialProps ({ req }) {
static async getInitialProps ({ req }) {
let userAgent
if (process.browser) {
userAgent = navigator.userAgent
......@@ -25,6 +25,7 @@ class Index extends Component {
static contextTypes = { theme: PropTypes.object }
render () {
const { userAgent } = this.props
return (
<ThemeWrapper
style={{
......@@ -35,12 +36,13 @@ class Index extends Component {
alignItems: 'center',
justifyContent: 'space-around'
}}
theme={getTheme({ userAgent: this.props.userAgent })}
theme={getTheme({ userAgent })}
>
<Button>Test Button</Button>
<DatePicker />
<ColorPicker />
<ProgressRing size={50} />
<p style={{ textAlign: 'center' }}>{userAgent.slice(12)}...</p>
</ThemeWrapper>
)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment