You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when I do a long async handleSubmit I can modify the input fields of the form and it will affect the data returned by handleSubmit onValid callback. This appears to only happen when the yupResolver is being used. The joiResolver and built-in validation does not have this issue.
It appears that yupResolver passes back a reference (instead of a clone) of the live field values when it returns from validation. That is unless one does some sort of transform with yup e.g. trim on any input, after which it will return a clone.
I think this is unexpected behavior and validation should always return a clone of the data as submitted and is not affected by interim form changes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
CSB:
https://codesandbox.io/p/sandbox/react-hook-form-yup-joi-data-change-during-submit-c55sdh
I noticed that when I do a long async handleSubmit I can modify the input fields of the form and it will affect the data returned by handleSubmit onValid callback. This appears to only happen when the yupResolver is being used. The joiResolver and built-in validation does not have this issue.
It appears that yupResolver passes back a reference (instead of a clone) of the live field values when it returns from validation. That is unless one does some sort of transform with yup e.g. trim on any input, after which it will return a clone.
I think this is unexpected behavior and validation should always return a clone of the data as submitted and is not affected by interim form changes.
Beta Was this translation helpful? Give feedback.
All reactions