From 9b3ad051a8bbba248da3bc1d5893c30bcff8211e Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 29 Aug 2018 19:44:03 +0800 Subject: [PATCH] fix menu data passing --- src/layouts/BasicLayout.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index dd6f0a74..18b6d0d3 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -57,8 +57,8 @@ const menuData = formatter(routerConfig[1].routes); */ const getBreadcrumbNameMap = memoizeOne(menu => { const routerMap = {}; - const mergeMenuAndRouter = () => { - menuData.forEach(menuItem => { + const mergeMenuAndRouter = data => { + data.forEach(menuItem => { if (menuItem.children) { mergeMenuAndRouter(menuItem.children); } @@ -100,8 +100,7 @@ class BasicLayout extends React.PureComponent { super(props); this.getPageTitle = memoizeOne(this.getPageTitle); // Because there are many places to be. So put it here - this.breadcrumbNameMap = getBreadcrumbNameMap(); - console.log(this.breadcrumbNameMap); + this.breadcrumbNameMap = getBreadcrumbNameMap(menuData); } state = { @@ -133,7 +132,7 @@ class BasicLayout extends React.PureComponent { } componentDidUpdate() { - this.breadcrumbNameMap = getBreadcrumbNameMap(); + this.breadcrumbNameMap = getBreadcrumbNameMap(menuData); } componentWillUnmount() { @@ -231,6 +230,7 @@ class BasicLayout extends React.PureComponent { Authorized={Authorized} theme={silderTheme} onCollapse={this.handleMenuCollapse} + menuData={menuData} {...this.props} /> )} -- GitLab