formsy-react
formsy-react copied to clipboard
Imperative api reset() caused form onChange event fired for each field.
For example I have a form with 3 input fields, then call formsy.reset({}), onChange event will be fired 3 times(each field will trigger one onChange event on Formsy component), so if I have 10 fields, onChange will be fired 10 times if I use reset function. And I believe this reset process should be batched and fire onChange event only after all fields' value are updated. https://github.com/formsy/formsy-react/blob/master/src/Formsy.ts#L243
I added below if you click "Reset Model" you could see 3 lines output. https://codesandbox.io/s/react-playground-6m7if?file=/index.js
Debug info,
When calling reset() the following chain is triggered:
reset() -> forEach(input).resetValue -> input.setState(prestine) -> validate -> onChange
Looks like the flag canChange is not solving the issue.