react-component / form

React High Order Form Component(web & react-native)
http://react-component.github.io/form/
MIT License
1.81k stars 296 forks source link

can't get fields value in onValuesChange callback when native input. #528

Open senwong opened 3 years ago

senwong commented 3 years ago

codesandbox demo

I want use form.getFieldsValue function in onValuesChange callback. But When typing in the input element,form.getFieldsValue can not get the value. image

But when changing field value by form.setFieldsValue function, in onValuesChange callback can get field value. Is this by design? image

In createBaseForm.js in this.setFieldsValue function, onValuesChange callback is invoked after this.setFields. https://github.com/react-component/form/blob/f02b478c59c178ea9ee28cca3326ad1c4ed37f02/src/createBaseForm.js#L370 image

But in this.onCollect function, onValuesChange callback is invoked before this.setFields. Is this by design? https://github.com/react-component/form/blob/f02b478c59c178ea9ee28cca3326ad1c4ed37f02/src/createBaseForm.js#L133 image