Browse Source

fix #1532 menu select bug

jim 8 years ago
parent
commit
6e3422fef3
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/routes/Account/Settings/Info.js

+ 9 - 0
src/routes/Account/Settings/Info.js

@@ -19,6 +19,15 @@ const menuMap = {
   currentUser: user.currentUser,
   currentUser: user.currentUser,
 }))
 }))
 export default class Info extends Component {
 export default class Info extends Component {
+  static getDerivedStateFromProps(props, state) {
+    const { match, location } = props;
+    let selectKey = location.pathname.replace(`${match.path}/`, '');
+    selectKey = menuMap[selectKey] ? selectKey : 'base';
+    if (selectKey !== state.selectKey) {
+      return { selectKey };
+    }
+    return null;
+  }
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
     const { match, location } = props;
     const { match, location } = props;