From 0795cb15c350f683c417b22a643345e988dcc340 Mon Sep 17 00:00:00 2001 From: GervinFung Date: Sun, 22 Sep 2024 17:16:04 +0800 Subject: [PATCH] refactor(component): improve document component --- apps/web/pages/_document.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/web/pages/_document.tsx b/apps/web/pages/_document.tsx index 8899d5b..3953aaa 100644 --- a/apps/web/pages/_document.tsx +++ b/apps/web/pages/_document.tsx @@ -4,7 +4,7 @@ import Document, { Head, Main, NextScript, Html } from 'next/document'; import React from 'react'; export default class Doc extends Document { - static override getInitialProps = async (context: DocumentContext) => { + static override async getInitialProps(context: DocumentContext) { const { renderPage: originalRenderPage } = context; // Run the React rendering logic synchronously @@ -22,10 +22,10 @@ export default class Doc extends Document { }; // Run the parent `getInitialProps`, it now includes the custom `renderPage` - return await Document.getInitialProps(context); - }; + return await super.getInitialProps(context); + } - override render = () => { + override render() { return ( @@ -43,5 +43,5 @@ export default class Doc extends Document { ); - }; + } }