From a2d9a5780f486c96fe4f159461df1a1e6ddc8b0f Mon Sep 17 00:00:00 2001 From: yoyo837 Date: Tue, 14 Aug 2018 16:48:44 +0800 Subject: [PATCH] find --- src/layouts/BasicLayout.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index e1a3363f..781d6dbd 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -132,15 +132,10 @@ export default class BasicLayout extends React.PureComponent { const { routerData, location } = this.props; const { pathname } = location; let title = 'Ant Design Pro'; - let currRouterData = null; // match params path - Object.keys(routerData).some(key => { - if (pathToRegexp(key).test(pathname)) { - currRouterData = routerData[key]; - return true; - } - return false; - }); + const currRouterData = (Object.entries(routerData).find(([key]) => + pathToRegexp(key).test(pathname) + ) || [])[1]; if (currRouterData && currRouterData.name) { title = `${currRouterData.name} - Ant Design Pro`; } -- GitLab