import './resolve-hooks'; import { ServerContainer, ServerContainerRef } from '@react-navigation/native'; import Koa from 'koa'; import * as React from 'react'; import ReactDOMServer from 'react-dom/server'; import { AppRegistry } from 'react-native-web'; import App from '../src/index'; AppRegistry.registerComponent('App', () => App); const PORT = process.env.PORT || 3275; const app = new Koa(); app.use(async (ctx) => { const { element, getStyleElement } = AppRegistry.getApplication('App'); const ref = React.createRef(); const html = ReactDOMServer.renderToString( {element} ); const css = ReactDOMServer.renderToStaticMarkup(getStyleElement()); const document = ` ${css} ${ref.current?.getCurrentOptions()?.title}
${html}
`; ctx.body = document; }); app.listen(PORT, () => { console.log(`Running at http://localhost:${PORT}`); });