What is the correct way to get values from a form controlled by redux-form after each form update? I need to submit an action every time the form changes using the values entered into the form.
My current solution gets the old values, not the ones that have just been updated.
onFormChange(e) { const { fieldValue1, fieldValue2, fieldValue3 } = this.props.fields; console.log(fieldValue1.value, fieldValue2.value, fieldValue3.value); } render() { return ( <form onChange={this.onFormChange}>
My other solution is this, but I don't know how reliable it is:
onFormChange(e) { console.log(e); setTimeout(() => { const { fieldValue1, fieldValue2, fieldValue3 } = this.props.fields; console.log(fieldValue1.value, fieldValue2.value, fieldValue3.value); }, 0); }
source share