mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Check if App / Document are valid React Components (#5907)
We already checked if Document is a valid component, but we didn't yet for App.
This commit is contained in:
parent
9c4eefcdbf
commit
581e193a72
|
@ -136,9 +136,15 @@ export async function renderToHTML (req: IncomingMessage, res: ServerResponse, p
|
||||||
if (!isValidElementType(Component)) {
|
if (!isValidElementType(Component)) {
|
||||||
throw new Error(`The default export is not a React Component in page: "${pathname}"`)
|
throw new Error(`The default export is not a React Component in page: "${pathname}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isValidElementType(App)) {
|
||||||
|
throw new Error(`The default export is not a React Component in page: "/_app"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Document.prototype || !Document.prototype.isReactComponent) throw new Error('_document.js is not exporting a React component')
|
if (!isValidElementType(Document)) {
|
||||||
|
throw new Error(`The default export is not a React Component in page: "/_document"`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const asPath = req.url
|
const asPath = req.url
|
||||||
const ctx = { err, req, res, pathname, query, asPath }
|
const ctx = { err, req, res, pathname, query, asPath }
|
||||||
|
|
Loading…
Reference in a new issue