-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Closed
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.
Description
What version of Next.js are you using?
11.0.1
What version of Node.js are you using?
12.18.1
What browser are you using?
N/A
What operating system are you using?
macOS
How are you deploying your application?
N/A
Describe the Bug
If i use spread operators to pass props into something in _document, like a <link
component, the build fails.
I was able to replicate this on stackblitz as well as in my own applications.
import Document, { Html, Head, Main, NextScript } from 'next/document';
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx);
return { ...initialProps };
}
render() {
const things = { className: 'test' };
return (
<Html>
<Head />
<link {...things} />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
export default MyDocument;
Get the following error
Failed to compile.
./pages/_document.js
Module parse failed: Cannot read property 'forEach' of undefined
File was processed with these loaders:
* ./node_modules/next/dist/build/babel/loader/index.js
You may need an additional loader to handle the result of these loaders.
TypeError: Cannot read property 'forEach' of undefined
> Build error occurred
Error: > Build failed because of webpack errors
at eval (/home/projects/nextjs-hn64hn/node_modules/next/dist/build/index.js:15:924)
at async Span.traceAsyncFn (/home/projects/nextjs-hn64hn/node_modules/next/dist/telemetry/trace/trace.js:6:584)
Expected Behavior
The build should pass
To Reproduce
Use a spread operator on a html element in _document
bmathews
Metadata
Metadata
Assignees
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.