Add server-side hydration of initial config+status. Closes #1964

This commit is contained in:
Gabe Kangas
2022-09-10 15:37:07 -07:00
parent 92ef860387
commit 42ff0cdb01
6 changed files with 114 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
/* eslint-disable react/no-danger */
/* eslint-disable react/no-unescaped-entities */
import { Layout } from 'antd';
import { useRecoilValue } from 'recoil';
import Head from 'next/head';
@@ -27,6 +29,11 @@ export const Main: FC = () => {
setupNoLinkReferrer(layoutRef.current);
}, []);
const hydrationScript = `
window.statusHydration = {{.StatusJSON}};
window.configHydration = {{.ServerConfigJSON}};
`;
return (
<>
<Head>
@@ -86,6 +93,7 @@ export const Main: FC = () => {
<meta name="theme-color" content="#ffffff" />
<style>{customStyles}</style>
<script dangerouslySetInnerHTML={{ __html: hydrationScript }} />
</Head>
<ClientConfigStore />