From 696409ea1c45b973e41d050119538ddcd7d4c89f Mon Sep 17 00:00:00 2001 From: Simon Park Date: Fri, 25 Oct 2019 10:31:56 -0700 Subject: [PATCH] throws error if routes with exact property doesn't exist. also, in the case of default routes --- index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 51b3212..ec55ddc 100644 --- a/index.js +++ b/index.js @@ -163,16 +163,21 @@ function getMatchedRoute(children, { pathname }) { for (let i = 0; i < childrenArray.length; i++) { const child = childrenArray[i]; - const matches = matchPath(pathname, { - exact: child.props.exact, - path: child.props.path, - }); - + var matches=null; + try{ + matches = matchPath(pathname, { + exact: child.props.exact, + path: child.props.path, + }); + } + catch(e) + { + matches=null; + } if (matches) { return child; } } - return NO_MATCH; }