step 1, in parent component:
constructor(props) {
super(props);
this.state = {
checkState:"checked",
enable:true
}
}
this.setState({
checkState:"unChecked",
enable:false
})
step 2: before calling the subcomponent form
<FormE ref={this.saveFormRef} checkState={this.state.checkState} enable={this.state.enable}/>
step 3: form subcomponents
const { form,checkState,enable} = this.props;
const { getFieldDecorator } = this.props.form;
{getFieldDecorator("status", {
rules: [{ required: false}],
valuePropName:{checkState},
initialValue:{enable}
})(
<Switch checkedChildren="" unCheckedChildren=""/>
)}
run the error message, valuePropName: {checkState} how should I write here to set it dynamically? I"m much obliged!