Browse Source

fixed submenu collapsed when refresh page (#3494)

pull/3498/head
doudou 8 years ago
committed by 陈帅
parent
commit
54678ba63e
  1. 8
      src/components/SiderMenu/SiderMenu.js

8
src/components/SiderMenu/SiderMenu.js

@ -18,10 +18,14 @@ export default class SiderMenu extends PureComponent {
} }
static getDerivedStateFromProps(props, state) { static getDerivedStateFromProps(props, state) {
const { pathname } = state; const { pathname, flatMenuKeysLen } = state;
if (props.location.pathname !== pathname) { if (
props.location.pathname !== pathname ||
props.flatMenuKeys.length !== flatMenuKeysLen
) {
return { return {
pathname: props.location.pathname, pathname: props.location.pathname,
flatMenuKeysLen: props.flatMenuKeys.length,
openKeys: getDefaultCollapsedSubMenus(props), openKeys: getDefaultCollapsedSubMenus(props),
}; };
} }

Loading…
Cancel
Save