ソースを参照

Fix Switch components not getting set with the default value the first time they render

Add support for 'string' boolean values in case the server sends the default boolean values as string.
Sergiu Miclea 9 年 前
コミット
31b8fb130f

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

@@ -37,6 +37,10 @@ class Switch extends Component {
     }
     }
   }
   }
 
 
+  componentWillReceiveProps(newProps) {
+    this.setState({ checked: newProps.checked })
+  }
+
   handleChange(e) {
   handleChange(e) {
     if (this.props.onChange) {
     if (this.props.onChange) {
       this.props.onChange(e)
       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)} />
               <InfoIcon text={Helper.getCloudFieldDescription(field.name)} />
             </div>
             </div>
             <Switch
             <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)}
               onChange={(e) => this.handleOptionsFieldChange(e, field)}
               checkedLabel="Yes"
               checkedLabel="Yes"
               uncheckedLabel="No"
               uncheckedLabel="No"