From c93b0169a500427ee5fdd3c2977886c86aa3d59a Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 30 Aug 2018 14:48:03 +0800 Subject: [PATCH] should not setState before mount --- src/pages/Account/Settings/Info.js | 39 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/pages/Account/Settings/Info.js b/src/pages/Account/Settings/Info.js index 0b0adb41..de7b86e4 100644 --- a/src/pages/Account/Settings/Info.js +++ b/src/pages/Account/Settings/Info.js @@ -15,30 +15,27 @@ export default class Info extends Component { constructor(props) { super(props); const { match, location } = props; + const menuMap = { + base: , + security: ( + + ), + binding: ( + + ), + notification: ( + + ), + }; + const key = location.pathname.replace(`${match.path}/`, ''); this.state = { mode: 'inline', - menuMap: { - base: , - security: ( - - ), - binding: ( - - ), - notification: ( - - ), - }, + menuMap, + selectKey: menuMap[key] ? key : 'base', }; - let key = location.pathname.replace(`${match.path}/`, ''); - const { menuMap } = this.state; - key = menuMap[key] ? key : 'base'; - this.setState({ - selectKey: key, - }); } static getDerivedStateFromProps(props, state) { -- GitLab