【发布时间】:2017-08-12 20:52:38
【问题描述】:
我目前正在构建一个组件以允许用户编辑他们的个人资料设置。该表单具有以下字段:
first_name
last_name
redux 表单当前正在正确设置 initialValues,如下所示:
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)
【问题讨论】:
标签: reactjs redux redux-form react-redux-form