2018-02-13 16:42:31 +00:00
|
|
|
import Document, { Head, Main, NextScript } from 'next/document'
|
|
|
|
import React from 'react'
|
|
|
|
import { AppRegistry } from 'react-native-web'
|
|
|
|
|
2018-07-15 18:59:20 +00:00
|
|
|
// Force Next-generated DOM elements to fill their parent's height
|
2018-02-13 16:42:31 +00:00
|
|
|
const normalizeNextElements = `
|
|
|
|
#__next {
|
2018-05-23 20:47:16 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2018-02-13 16:42:31 +00:00
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
export default class MyDocument extends Document {
|
|
|
|
static async getInitialProps ({ renderPage }) {
|
|
|
|
AppRegistry.registerComponent('Main', () => Main)
|
|
|
|
const { getStyleElement } = AppRegistry.getApplication('Main')
|
|
|
|
const page = renderPage()
|
|
|
|
const styles = [
|
2018-07-15 18:59:20 +00:00
|
|
|
<style dangerouslySetInnerHTML={{ __html: normalizeNextElements }} />,
|
2018-02-13 16:42:31 +00:00
|
|
|
getStyleElement()
|
|
|
|
]
|
2018-07-15 18:59:20 +00:00
|
|
|
return { ...page, styles: React.Children.toArray(styles) }
|
2018-02-13 16:42:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
2018-07-15 18:59:20 +00:00
|
|
|
<html style={{ height: '100%' }}>
|
2018-02-13 16:42:31 +00:00
|
|
|
<Head>
|
|
|
|
<title>react-native-web</title>
|
2018-05-23 20:44:22 +00:00
|
|
|
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
2018-02-13 16:42:31 +00:00
|
|
|
</Head>
|
2018-07-15 18:59:20 +00:00
|
|
|
<body style={{ height: '100%', overflow: 'hidden' }}>
|
2018-02-13 16:42:31 +00:00
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|