1
0
Fork 0
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:
Tim Neutkens 2018-12-17 17:42:40 +01:00 committed by GitHub
parent 9c4eefcdbf
commit 581e193a72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -136,9 +136,15 @@ export async function renderToHTML (req: IncomingMessage, res: ServerResponse, p
if (!isValidElementType(Component)) {
throw new Error(`The default export is not a React Component in page: "${pathname}"`)
}
}
if (!Document.prototype || !Document.prototype.isReactComponent) throw new Error('_document.js is not exporting a React component')
if (!isValidElementType(App)) {
throw new Error(`The default export is not a React Component in page: "/_app"`)
}
if (!isValidElementType(Document)) {
throw new Error(`The default export is not a React Component in page: "/_document"`)
}
}
const asPath = req.url
const ctx = { err, req, res, pathname, query, asPath }