现在我正在用react+nodejs+nextserver+express制作一个迷你项目
并发生意外错误
我不知道为什么_document.js中会出现错误。
如果您知道原因,请告诉我,谢谢
错误:
Error: "MyDocument.getInitialProps()" should resolve to an object with a "html" prop set with a valid html string
at Object.renderToHTML (C:\node_bird_44\front\node_modules\next\dist\next-server\server\render.js:338:15)
at process._tickCallback (internal/process/next_tick.js:68:7)
GET / 500 11240.415 ms - 21
[ event ] disposing inactive page(s): /, /_error
Run Code Online (Sandbox Code Playgroud)
import React from 'react';
import Document , {Main, NextScript } from 'next/document';
import Helmet from 'react-helmet';
class MyDocument extends Document {
static getInitialProps(context) {
return { helmet: Helmet.renderStatic()};
}
render() {
const { htmlAttributes, bodyAttributes, ...helmet } …Run Code Online (Sandbox Code Playgroud) reactjs ×1