Skip to content

Commit

Permalink
fix: fast equal before deciding value was changed closes #3808
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Jun 28, 2022
1 parent fd0500c commit 3d582ec
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/vee-validate/src/useField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,20 @@ function _useField<TValue = unknown>(

let unwatchValue: WatchStopHandle;
function watchValue() {
unwatchValue = watch(value, validateOnValueUpdate ? validateWithStateMutation : validateValidStateOnly, {
deep: true,
});
unwatchValue = watch(
value,
(val, oldVal) => {
if (isEqual(val, oldVal)) {
return;
}

const validateFn = validateOnValueUpdate ? validateWithStateMutation : validateValidStateOnly;
validateFn();
},
{
deep: true,
}
);
}

watchValue();
Expand Down

0 comments on commit 3d582ec

Please sign in to comment.