-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve setup for react-native-web with next.js
- Loading branch information
1 parent
17bccd1
commit e350f1a
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Children} from 'react'; | ||
import Document, {Html, Head, Main, NextScript} from 'next/document'; | ||
import {AppRegistry} from 'react-native'; | ||
import config from '../app.json'; | ||
// Force Next-generated DOM elements to fill their parent's height | ||
const normalizeNextElements = ` | ||
#__next { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
} | ||
`; | ||
|
||
export default class MyDocument extends Document { | ||
static async getInitialProps({renderPage}) { | ||
AppRegistry.registerComponent(config.name, () => Main); | ||
const {getStyleElement} = AppRegistry.getApplication(config.name); | ||
const page = await renderPage(); | ||
const styles = [ | ||
<style dangerouslySetInnerHTML={{__html: normalizeNextElements}} />, | ||
getStyleElement(), | ||
]; | ||
return {...page, styles: Children.toArray(styles)}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<Html style={{height: '100%'}}> | ||
<Head /> | ||
<body style={{height: '100%', overflow: 'hidden'}}> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
} |
e350f1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
luna – ./
luna-gamma.vercel.app
luna-git-nextjs-criszz77.vercel.app
luna-criszz77.vercel.app