2017-08-29 41 views
0

我正在使用reduxForm。Redux-form onChange在窗體上沒有正確觸發

我創建的組件與

<form> 
    <Field name="example" component="SomeCustomInputComponent" type="text"/> 
</form> 

我申請全成分與的onChange功能reduxForm:

export default reduxForm({ 
    form: 'settingsAuthorization', 
    destroyOnUnmount: false, 
    forceUnregisterOnUnmount: true, 
    enableReinitialize: true, 
    onChange: (value, dispatch, props) => { 
     console.warn(value); 
    } 
})(component); 

,並把一些值我的onChane動作後沒有做任何事情。

最有趣的事情是,我想我的onChange功能的調試使用我注意到: Debbug IMG

這裏nextProps.values都同樣喜歡this.props.values。而且當我更改表單上的內容時。 nextProps和this.props的值。被初始化。

但在終極版devtool網站我得到出動終極版表格/變化行動的信息:

@@終極版,form.CHANGE

而且我可以看到,表格值'老字號'=> '新名稱'

: - > FORM_NAME - - >值>名稱

形式:全球存儲(store.form.form_name.values.name)內改變

而且當我把:

onChange: (value, dispatch, props) => { 
     console.warn(value); 
    } 

財產,我有我的網站上的一切其他形式的順利。

如何通過使用react-redux來修復我的第一個對變化事件做出反應的問題?

回答

0

您需要將表格縮減器添加到您的redux縮減器中,以便您的表單狀態在redux存儲中存儲和更新。如何如果你不使用終極版爲別的,就做這個here

文檔,你需要createStore,幷包裹在反應 - 終極版Provider您的應用程序,更對here

+0

我做。但我沒有提到它。謝謝你的評論。 –