Commit 6f4925c1 authored by David Calhoun's avatar David Calhoun Committed by Tim Neutkens

[change] Update RNW example (#4787)

parent 0f87368d
{
"presets": ["next/babel"],
"plugins": ["react-native-web"]
"plugins": [
["react-native-web", { commonjs: true }]
]
}
......@@ -6,12 +6,11 @@
"start": "next start"
},
"dependencies": {
"babel-plugin-react-native-web": "^0.8.8",
"next": "latest",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-native-web": "^0.4.0"
},
"devDependencies": {
"babel-plugin-react-native-web": "^0.4.0"
"react": "^16.4.1",
"react-art": "^16.4.1",
"react-dom": "^16.4.1",
"react-native-web": "^0.8.8"
}
}
......@@ -2,13 +2,8 @@ import Document, { Head, Main, NextScript } from 'next/document'
import React from 'react'
import { AppRegistry } from 'react-native-web'
let index = 0
// Force Next-generated DOM elements to fill their parent's height.
// Not required for using of react-native-web, but helps normalize
// layout for top-level wrapping elements.
// Force Next-generated DOM elements to fill their parent's height
const normalizeNextElements = `
body > div:first-child,
#__next {
display: flex;
flex-direction: column;
......@@ -22,23 +17,20 @@ export default class MyDocument extends Document {
const { getStyleElement } = AppRegistry.getApplication('Main')
const page = renderPage()
const styles = [
<style
key={index++}
dangerouslySetInnerHTML={{ __html: normalizeNextElements }}
/>,
<style dangerouslySetInnerHTML={{ __html: normalizeNextElements }} />,
getStyleElement()
]
return { ...page, styles }
return { ...page, styles: React.Children.toArray(styles) }
}
render () {
return (
<html style={{ height: '100%', width: '100%' }}>
<html style={{ height: '100%' }}>
<Head>
<title>react-native-web</title>
<meta name='viewport' content='width=device-width, initial-scale=1' />
</Head>
<body style={{ height: '100%', width: '100%', overflowY: 'scroll' }}>
<body style={{ height: '100%', overflow: 'hidden' }}>
<Main />
<NextScript />
</body>
......
......@@ -3,8 +3,8 @@ import { StyleSheet, Text, View } from 'react-native'
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
flexGrow: 1,
justifyContent: 'center'
},
text: {
......
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