SetError/ClearErrors causes watch to trigger #3494
-
I am trying to create a global error based on the values of multiple fields together. I am using useEffect on the watched form value to check for field changes, and then setError or clearErrors to update the error status. The issue is that setError/ClearErrors is causing the useEffect to run again (even though the fields themselves have not changed), thereby resulting in an infinite loop. Sandbox: What am I doing wrong? How can I achieve a global error based on multiple fields? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
wouldn't it be easier just to attach an |
Beta Was this translation helpful? Give feedback.
-
I had the same problem with you. |
Beta Was this translation helpful? Give feedback.
-
I ran into the same issue using clearERrors. I fixed it by preventing the clearErrors function to run if there are no errors to clear
|
Beta Was this translation helpful? Give feedback.
wouldn't it be easier just to attach an
onChange
andsetError
?