1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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

* fix: Update react-uwp example support Next 3

* style: Update linted codes
This commit is contained in:
myxvisual 2017-07-08 20:12:01 +08:00 committed by Tim Neutkens
parent 874f9a78ef
commit a0d85d8bee
2 changed files with 8 additions and 6 deletions

View file

@ -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 () {

View file

@ -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>
)
}