Unverified Commit 581e193a authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

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.
parent 9c4eefcd
......@@ -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 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment