Add styles to examples SSR

Close #2308
Fix #2309
This commit is contained in:
yuxz
2022-06-25 13:23:21 +08:00
committed by Nicolas Gallagher
parent 2be582b6e0
commit 43b60d1eed

View 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>
);
}
}