Hello there,
currently my code on the server looks like this:
onPageLoad((sink) => {
const store = const store = createStore();
const appJsx = (
<HelmetProvider context={helmetContext}>
<Provider store={store}>
<ReduxIntlProvider>
<StaticRouter location={sink.request.url} context={context}>
<App />
</StaticRouter>
</ReduxIntlProvider>
</Provider>
</HelmetProvider>);
sink.renderIntoElementById('root', renderToString(appJsx));
const { helmet } = helmetContext;
sink.appendToHead(helmet.meta.toString());
sink.appendToHead(helmet.link.toString());
sink.appendToHead(helmet.title.toString());
sink.appendToBody(`
<script>
window.__PRELOADED_STATE__ = ${JSON.stringify(store.getState()).replace(/</g, '\\u003c')}
</script>
`);
}
I would like to use renderToNodeStream in order to improve TTFB. The example at https://github.com/staylor/react-helmet-async is also not that clear to me. I’m also not familiar what server-render does with the sink object behind the scene.
Has someone a working example or a suggestion how this might work?
Best regards,
HK