Redux的表單版本: 6.6.3終極版-形式調用備用從ComponentWillRecieveProps提交
反應版本: 15.5.0
我想調用不同componentWillRecieveProps功能在我的反應提交功能零件。
componentWillReceiveProps(nextProps) {
if (nextProps.updateTierConfigState == "ValidationFulfilled"
&& nextProps.updateMyConfigValidationClean) {
console.log('CWRP calling submit()')
//this.props.submit(); //THIS CALLS DEFAULT on FORM's onSubmit
this.props.handleSubmit(this.updateSubmit().bind(this))
}
else {
this.props.handleSubmit(this.createSubmit().bind(this))
}
}
updateSubmit(values) {
//do stuff
}
createSubmit(values) {
//do stuff
}
我看到的例子是這樣的:https://github.com/erikras/redux-form/issues/711#issuecomment-191850962
但是,我一直沒能成功調用handleSubmit。它不會調用傳入的函數。
我已經調試到handleSubmit,它很快就返回調用指定的提交功能。
需要查看'this.props.handleSubmit'函數來調試它。 –
沒有直接關係,但我認爲你的if語句嵌套關閉。在if語句塊之後有兩個結束括號,另一個塊在'componentWillReceiveProps' – Jose
@Jose之外浮動,缺少的}只存在於上面的文章中,而不是在我的實際代碼中。仍然會糾正。 – Dranyar