Преглед изворни кода

Merge pull request #77 from smiclea/CORWEB-104

Fix Switch components not getting set with the default value the first time they render CORWEB-104
Dorin Paslaru пре 8 година
родитељ
комит
c054e37b03
2 измењених фајлова са 6 додато и 1 уклоњено
  1. 4 0
      src/components/Switch/Switch.js
  2. 2 1
      src/components/WizardOptions/WizardOptions.js

+ 4 - 0
src/components/Switch/Switch.js

@@ -37,6 +37,10 @@ class Switch extends Component {
     }
   }
 
+  componentWillReceiveProps(newProps) {
+    this.setState({ checked: newProps.checked })
+  }
+
   handleChange(e) {
     if (this.props.onChange) {
       this.props.onChange(e)

+ 2 - 1
src/components/WizardOptions/WizardOptions.js

@@ -203,7 +203,8 @@ class WizardOptions extends Reflux.Component {
               <InfoIcon text={Helper.getCloudFieldDescription(field.name)} />
             </div>
             <Switch
-              checked={this.state.destination_environment[field.name] === true}
+              checked={this.state.destination_environment[field.name] === true ||
+                this.state.destination_environment[field.name] === 'true'}
               onChange={(e) => this.handleOptionsFieldChange(e, field)}
               checkedLabel="Yes"
               uncheckedLabel="No"