diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index e1a3363fd83461880c37f6fff7c488926f0dbef4..781d6dbd6213c93f8f147a8c892105d20c9d7862 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`; }