Issue
My project is in https://github.com/Talita1996/NLW4
- I created a project with the command
yarn create next-app project_name
- I changed the extension of some files and added some code
- I installed typescript with the command
yarn add typescript @types/react @types/react-dom @types/node -D
On the first day everything worked fine, but today, when I call yarn dev
I get the error:
Solution
in your page/_document you need to extend Document class
import Document, { Html, Head, Main, NextScript } from 'next/document';
export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}
render() {
return (
<Html>
<Head>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Rajdhani:wght@600&display=swap" rel="stylesheet" />
</Head>
<body>
<Main/>
<NextScript/>
</body>
</Html>
);
}
}
Answered By - Anass TIssir
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.