Reactjs 使用redux表单,如何组合初始值的值?
我目前正在构建一个组件,允许用户编辑其配置文件设置。该表单包含如下字段:Reactjs 使用redux表单,如何组合初始值的值?,reactjs,redux,redux-form,react-redux-form,Reactjs,Redux,Redux Form,React Redux Form,我目前正在构建一个组件,允许用户编辑其配置文件设置。该表单包含如下字段: first_name last_name redux表单当前正在正确设置初始值,如下所示: Profile = connect( state => ({ initialValues: state.profiles.find(el => el.id === state.currentUser.user_id) }) )(Profile) 问题是我还需要在此表单中包含UserSettings,所
first_name
last_name
redux表单当前正在正确设置初始值,如下所示:
Profile = connect(
state => ({
initialValues: state.profiles.find(el => el.id === state.currentUser.user_id)
})
)(Profile)
问题是我还需要在此表单中包含UserSettings,所以我尝试这样做:
Profile = connect(
state => ({
initialValues: state.profiles.find(el => el.id === state.currentUser.user_id),
initialValues: {
notification_email_product_feature_updates: state.user_settings.notification_email_product_feature_updates
}
})
)(Profile)
但上述方法不起作用。。。如何添加处于不同状态对象中的其他初始值
我还尝试了以下操作,但这并没有设置值:
Profile = connect(
state => ({
initialValues: {
first_name: state.profiles.find(el => el.id === state.currentUser.user_id) ? state.profiles.find(el => el.id === state.currentUser.user_id).first_name : '',
}
})
)(Profile)
请尝试下面的代码,但您必须确保您获得了此状态下的内容。用户设置。通知\u电子邮件\u产品\u功能\u更新:
Profile = connect(
state => ({
initialValues:
{
currentUser: state.profiles.find(el => el.id === state.currentUser.user_id),
settings: state.user_settings.notification_email_product_feature_updates
}
})
)(Profile)
请尝试下面的代码,但您必须确保您获得了此状态下的内容。用户设置。通知\u电子邮件\u产品\u功能\u更新:
Profile = connect(
state => ({
initialValues:
{
currentUser: state.profiles.find(el => el.id === state.currentUser.user_id),
settings: state.user_settings.notification_email_product_feature_updates
}
})
)(Profile)