考虑这个使用版本的例子5.3.2
:
@reduxForm({
form: 'contact',
}, (state, ownProps) => ({ // check the current component's props
initialValues: ownProps.data.loading
? '' // nothing if still loading
: ownProps.data.allPeople.people[0].name, // data if done fetching
}))
记录在案的版本演示代码>6
没有显示此函数回调模式的可能性:
// Decorate with reduxForm(). It will read the initialValues prop provided by connect()
InitializeFromStateForm = reduxForm({
form: 'initializeFromState' // a unique identifier for this form
})(InitializeFromStateForm)
// You have to connect() to any reducers that you wish to connect to yourself
InitializeFromStateForm = connect(
state => ({
initialValues: state.account.data // pull initial values from account reducer
}),
{ load: loadAccount } // bind account loading action creator
)(InitializeFromStateForm)
第一种模式仍然可能吗?如果是这样,它是如何工作的?它在任何地方都有记录吗?我看到我的组件道具中有一个initialize
调度程序。是这样吗?