diff --git a/lib/utils.js b/lib/utils.js index 22faec6a62f2a..2474870175c41 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -54,6 +54,14 @@ export function isResSent (res) { } export async function loadGetInitialProps (Component, ctx) { + if (process.env.NODE_ENV !== 'production') { + if (Component.prototype && Component.prototype.getInitialProps) { + const compName = getDisplayName(Component) + const message = `"${compName}.getInitialProps()" is defined as an instance method.` + throw new Error(message) + } + } + if (!Component.getInitialProps) return {} const props = await Component.getInitialProps(ctx)