Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
6f4925c1
Commit
6f4925c1
authored
Jul 15, 2018
by
David Calhoun
Committed by
Tim Neutkens
Jul 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[change] Update RNW example (#4787)
parent
0f87368d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
21 deletions
+14
-21
.babelrc
examples/with-react-native-web/.babelrc
+3
-1
package.json
examples/with-react-native-web/package.json
+5
-6
_document.js
examples/with-react-native-web/pages/_document.js
+5
-13
index.js
examples/with-react-native-web/pages/index.js
+1
-1
No files found.
examples/with-react-native-web/.babelrc
View file @
6f4925c1
{
{
"presets": ["next/babel"],
"presets": ["next/babel"],
"plugins": ["react-native-web"]
"plugins": [
["react-native-web", { commonjs: true }]
]
}
}
examples/with-react-native-web/package.json
View file @
6f4925c1
...
@@ -6,12 +6,11 @@
...
@@ -6,12 +6,11 @@
"start"
:
"next start"
"start"
:
"next start"
},
},
"dependencies"
:
{
"dependencies"
:
{
"babel-plugin-react-native-web"
:
"^0.8.8"
,
"next"
:
"latest"
,
"next"
:
"latest"
,
"react"
:
"^16.0.0"
,
"react"
:
"^16.4.1"
,
"react-dom"
:
"^16.0.0"
,
"react-art"
:
"^16.4.1"
,
"react-native-web"
:
"^0.4.0"
"react-dom"
:
"^16.4.1"
,
},
"react-native-web"
:
"^0.8.8"
"devDependencies"
:
{
"babel-plugin-react-native-web"
:
"^0.4.0"
}
}
}
}
examples/with-react-native-web/pages/_document.js
View file @
6f4925c1
...
@@ -2,13 +2,8 @@ import Document, { Head, Main, NextScript } from 'next/document'
...
@@ -2,13 +2,8 @@ import Document, { Head, Main, NextScript } from 'next/document'
import
React
from
'react'
import
React
from
'react'
import
{
AppRegistry
}
from
'react-native-web'
import
{
AppRegistry
}
from
'react-native-web'
let
index
=
0
// Force Next-generated DOM elements to fill their parent's height
// 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.
const
normalizeNextElements
=
`
const
normalizeNextElements
=
`
body > div:first-child,
#__next {
#__next {
display: flex;
display: flex;
flex-direction: column;
flex-direction: column;
...
@@ -22,23 +17,20 @@ export default class MyDocument extends Document {
...
@@ -22,23 +17,20 @@ export default class MyDocument extends Document {
const
{
getStyleElement
}
=
AppRegistry
.
getApplication
(
'Main'
)
const
{
getStyleElement
}
=
AppRegistry
.
getApplication
(
'Main'
)
const
page
=
renderPage
()
const
page
=
renderPage
()
const
styles
=
[
const
styles
=
[
<
style
<
style
dangerouslySetInnerHTML
=
{{
__html
:
normalizeNextElements
}}
/>
,
key
=
{
index
++
}
dangerouslySetInnerHTML
=
{{
__html
:
normalizeNextElements
}}
/>
,
getStyleElement
()
getStyleElement
()
]
]
return
{
...
page
,
styles
}
return
{
...
page
,
styles
:
React
.
Children
.
toArray
(
styles
)
}
}
}
render
()
{
render
()
{
return
(
return
(
<
html
style
=
{{
height
:
'100%'
,
width
:
'100%'
}}
>
<
html
style
=
{{
height
:
'100%'
}}
>
<
Head
>
<
Head
>
<
title
>
react
-
native
-
web
<
/title
>
<
title
>
react
-
native
-
web
<
/title
>
<
meta
name
=
'viewport'
content
=
'width=device-width, initial-scale=1'
/>
<
meta
name
=
'viewport'
content
=
'width=device-width, initial-scale=1'
/>
<
/Head
>
<
/Head
>
<
body
style
=
{{
height
:
'100%'
,
width
:
'100%'
,
overflowY
:
'scroll
'
}}
>
<
body
style
=
{{
height
:
'100%'
,
overflow
:
'hidden
'
}}
>
<
Main
/>
<
Main
/>
<
NextScript
/>
<
NextScript
/>
<
/body
>
<
/body
>
...
...
examples/with-react-native-web/pages/index.js
View file @
6f4925c1
...
@@ -3,8 +3,8 @@ import { StyleSheet, Text, View } from 'react-native'
...
@@ -3,8 +3,8 @@ import { StyleSheet, Text, View } from 'react-native'
const
styles
=
StyleSheet
.
create
({
const
styles
=
StyleSheet
.
create
({
container
:
{
container
:
{
flex
:
1
,
alignItems
:
'center'
,
alignItems
:
'center'
,
flexGrow
:
1
,
justifyContent
:
'center'
justifyContent
:
'center'
},
},
text
:
{
text
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment