how to update FieldArray elements with redux store variable

前端 未结 1 584
借酒劲吻你
借酒劲吻你 2021-01-15 19:18
  • I am using redux-form with a FieldArray.By default 1 element will be there in array and it is populated from JSON. I can add upto 3 elements in FieldArray component

相关标签:
1条回答
  • 2021-01-15 19:28

    Hi the issue is with the push statement in your function when updating states in the constructor or reducer use concat or spread operator[...]> I have made a sample over here please check

    onAddItem() {
            let list = [...this.state.items, {text:`Check 1`}];
            this.setState({items:list});
    }
    

    in your case you can do the following

    let arr = [...childList, newChild]
    

    then dispatch the arr

     dispatch(setDoc(arr));
    
    0 讨论(0)
提交回复
热议问题