diff options
author | Corey Hulen <corey@hulen.com> | 2015-09-02 16:57:05 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-09-02 16:57:05 -0700 |
commit | 2c06ec89feb783d10fa10c77ab4b192522e35f3d (patch) | |
tree | e4ebd6b5ea7358416394848da0e4becb7dda6cd3 /web/react/components/team_feature_tab.jsx | |
parent | f11f703158ae76f5cd3bec1f5c6226196af84c91 (diff) | |
parent | 7b70892c75aec62a7b4fa326b08fbda26d4e3262 (diff) | |
download | chat-2c06ec89feb783d10fa10c77ab4b192522e35f3d.tar.gz chat-2c06ec89feb783d10fa10c77ab4b192522e35f3d.tar.bz2 chat-2c06ec89feb783d10fa10c77ab4b192522e35f3d.zip |
Merge pull request #570 from rgarmsen2295/fix-initial-state-calls
Refactor remaining uses of getInitialState and componentWillMount
Diffstat (limited to 'web/react/components/team_feature_tab.jsx')
-rw-r--r-- | web/react/components/team_feature_tab.jsx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/web/react/components/team_feature_tab.jsx b/web/react/components/team_feature_tab.jsx index e5398332e..3251746b8 100644 --- a/web/react/components/team_feature_tab.jsx +++ b/web/react/components/team_feature_tab.jsx @@ -14,15 +14,9 @@ export default class FeatureTab extends React.Component { this.submitValetFeature = this.submitValetFeature.bind(this); this.handleValetRadio = this.handleValetRadio.bind(this); this.onUpdateSection = this.onUpdateSection.bind(this); + this.setupInitialState = this.setupInitialState.bind(this); - this.state = {}; - var team = this.props.team; - - if (team && team.allow_valet) { - this.state.allowValet = 'true'; - } else { - this.state.allowValet = 'false'; - } + this.state = this.setupInitialState(); } componentWillReceiveProps(newProps) { var team = newProps.team; @@ -44,7 +38,7 @@ export default class FeatureTab extends React.Component { AsyncClient.getMyTeam(); }.bind(this), function fail(err) { - var state = this.getInitialState(); + var state = this.setupInitialState(); state.serverError = err; this.setState(state); }.bind(this) @@ -62,6 +56,18 @@ export default class FeatureTab extends React.Component { this.props.updateSection('valet'); } } + setupInitialState() { + var allowValet; + var team = this.props.team; + + if (team && team.allow_valet) { + allowValet = 'true'; + } else { + allowValet = 'false'; + } + + return {allowValet: allowValet}; + } render() { var clientError = null; var serverError = null; |