From 6e3422fef31837c8016cc0d7d4d4962f04f327be Mon Sep 17 00:00:00 2001 From: jim Date: Wed, 6 Jun 2018 11:03:37 +0800 Subject: [PATCH] fix #1532 menu select bug --- src/routes/Account/Settings/Info.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/routes/Account/Settings/Info.js b/src/routes/Account/Settings/Info.js index 149b9f71..7c104fac 100644 --- a/src/routes/Account/Settings/Info.js +++ b/src/routes/Account/Settings/Info.js @@ -19,6 +19,15 @@ const menuMap = { currentUser: user.currentUser, })) 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) { super(props); const { match, location } = props; -- GitLab