mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-15 03:58:48 +00:00
25
packages/examples/pages/_document.js
Normal file
25
packages/examples/pages/_document.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Document, { Html, Head, Main, NextScript } from 'next/document';
|
||||
import { AppRegistry } from 'react-native';
|
||||
|
||||
export default class MyDocument extends Document {
|
||||
static async getInitialProps(ctx) {
|
||||
const { renderPage } = ctx;
|
||||
AppRegistry.registerComponent('rn', () => Main);
|
||||
const { getStyleElement } = AppRegistry.getApplication('rn');
|
||||
const page = await renderPage();
|
||||
const styles = getStyleElement();
|
||||
return { ...page, styles };
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Html>
|
||||
<Head />
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user