0
我想在簡單的Input redux表單字段中進行簡單的數據注入。 讓我解釋一下:在輸入字段上使用「更改」監聽器
我有一個大的形式,當用戶在「姓氏」輸入內寫入時,我只是想將值注入第二個字段作爲「LastNameFather」。
很簡單伊莫
我做了一個formvalueSelector,並獲得第一個輸入值。
const selecor = formValueSelector('MyForm')
const mapStateToProps = (state,props) => {
const name = selector(state,"nameOne")
return {
name : name
}}
而我使用componentWillReceiveProps來處理寫作,並使用道具更改注入我的價值。
componentWillReceiveProps = (props) => {
props.name != null ? props.change("name2",props.name) : null
}
現在,當我在我的第一個字段中寫入時,有無限的重新渲染。正如你所看到的,我必須在更改第二個字段之前測試props.name!= null。
無論如何,我錯過了什麼?
感謝
你是否將調度綁定到'props.change'? –
是的,我可以看到我的動作正確發送。 我不知道什麼錯。 – GreGGus
我不會走你自己的路@GreGGus,我更喜歡在'lastname'的'Field'上做'onBlur'監聽器,並且我會去'()=> props.change(...)'。 –