Handle browser Errors.
This commit is contained in:
+5
-3
@@ -38,15 +38,17 @@ export default function grabClientHydrationScript({ page_local_path }) {
|
||||
// txt += `window.__JSX_RUNTIME__ = JSXRuntime;\n\n`;
|
||||
txt += `const pageProps = window.__PAGE_PROPS__ || {};\n`;
|
||||
if (does_root_exist) {
|
||||
txt += `const component = <Root {...pageProps}><Page {...pageProps} /></Root>\n`;
|
||||
txt += `const component = <Root suppressHydrationWarning={true} {...pageProps}><Page {...pageProps} /></Root>\n`;
|
||||
}
|
||||
else {
|
||||
txt += `const component = <Page {...pageProps} />\n`;
|
||||
txt += `const component = <Page suppressHydrationWarning={true} {...pageProps} />\n`;
|
||||
}
|
||||
txt += `if (window.${ClientRootComponentWindowName}?.render) {\n`;
|
||||
txt += ` window.${ClientRootComponentWindowName}.render(component);\n`;
|
||||
txt += `} else {\n`;
|
||||
txt += ` const root = hydrateRoot(document.getElementById("${ClientRootElementIDName}"), component);\n\n`;
|
||||
txt += ` const root = hydrateRoot(document.getElementById("${ClientRootElementIDName}"), component, { onRecoverableError: () => {\n\n`;
|
||||
txt += ` console.log(\`Hydration Error.\`)\n\n`;
|
||||
txt += ` } });\n\n`;
|
||||
txt += ` window.${ClientRootComponentWindowName} = root;\n`;
|
||||
txt += ` window.__BUNEXT_RERENDER__ = (NewPage) => {\n`;
|
||||
txt += ` const props = window.__PAGE_PROPS__ || {};\n`;
|
||||
|
||||
Reference in New Issue
Block a user