从反应本机上的状态 Redux 表单中获取文本输入值



我有一个带有不同字段的代码。当从其他组件传递新值时,我有四个字段具有此值,我使用 this.state 生成她的值。

但是当我处理提交((时,此输入不会发送。我已经做了一个测试,一旦我已经加载了它们,就会更改她的值,现在是的,它们被发送了。

如何在句柄提交中接收这些值?

这是代码的一部分:

changeImage = (values) => {
if (values.type == "profile")
this.setState({changePersonalImage: true});
else if (values.type == "featured")
this.setState({changeFeaturedImage: true});
else if (values.type == "project")
this.setState({changeProjectImage: true});

this.setState(values);
}
render() {
return (
<View>  
<View>
{this.state.changePersonalImage &&
<View>
<Field name="personalImage_type" component={genericField} type="hidden" val={this.state.profile_type} />
<Field name="personalImage_fileName" component={genericField} type="hidden" val={this.state.profile_fileName} />
<Field name="personalImage_image" component={genericField} type="hidden" val={this.state.profile_image} />
<Field name="personalImage_isVertical" component={genericField} type="hidden" val={this.state.profile_isVertical} />
</View>
}
<TouchableOpacity
style={styles.btnRequest}
//onPress={this.props.handleSubmit(this.props.edit)}
onPress={this.props.handleSubmit((values) => {
console.log('valuess - handleSubmit');
console.log(values);
})}
>
<WhiteText style={styles.btnRequestText}>Save changes</WhiteText>                   
</TouchableOpacity>

已解决,

我在这篇文章中找到了一个解决方案 如何在 react native 中以 redux 形式设置隐藏字段?

问题是创建一个隐藏字段。解决方案是调用此方法:

this.props.change('Field_name', value)

最新更新