From 4be6a521eddd23b5ba4bfc3997e20cb8d4b81d30 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 5 Dec 2017 15:35:30 -0800 Subject: [PATCH] Make sure we show a nice message when there is no default export (#3400) --- lib/router/router.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/router/router.js b/lib/router/router.js index 1873002d..222499ab 100644 --- a/lib/router/router.js +++ b/lib/router/router.js @@ -199,6 +199,11 @@ export default class Router { } const { Component } = routeInfo + + if (typeof Component !== 'function') { + throw new Error(`The default export is not a React Component in page: "${pathname}"`) + } + const ctx = { pathname, query, asPath: as } routeInfo.props = await this.getInitialProps(Component, ctx)