app.get('*', (req, res) => { const initialAction = BlogApp.actionWithLocation({ path: req.path, params: req.query, }); const navigationState = BlogApp.navigationReducer( undefined, initialAction || BlogApp.Actions.default() ); const { html, style, styleElement } = AppRegistry.prerenderApplication('App', { initialProps: { navigationState, }, }); const activeChild = navigationState.children[navigationState.index]; const title = BlogApp.getTitle(activeChild); const renderedApplicationHTML = React.renderToStaticMarkup( <WebContainer html={html} title={title} styleElement={styleElement} /> ); res.send(renderedApplicationHTML); });
<RootRouter /> ); } } AppRegistry.registerComponent('SlackBooking', () => SlackBooking); // prerender the app const { html, style } = AppRegistry.prerenderApplication('SlackBooking', { initialProps }) // construct full page markup const HtmlShell = (html, style) => ( <html> <head> <meta charSet="utf-8" /> <meta content="initial-scale=1,width=device-width" name="viewport" /> {style} </head> <body> <div id="react-root" dangerouslySetInnerHTML={{ __html: html }} /> <script src="http://localhost:8080/webpack-dev-server.js"></script> </body> </html> ); React.renderToStaticMarkup(<HtmlShell html={html} style={style} />);