Summary
This PR is to fix this issue.
Fix infinite loop issue when setValue is used in react useEffect hook dependency.
The issue should occur with setTouched and setError
Causes
When component render, setValue, setTouched, setError arrow function reference is generated as new by getFieldHelpers interface.
Solution
Add useMemo to cache these arrow functions. This won't change the function references as long as fieldName is not changed.
Summary This PR is to fix this issue. Fix infinite loop issue when setValue is used in react useEffect hook dependency. The issue should occur with setTouched and setError
Causes When component render, setValue, setTouched, setError arrow function reference is generated as new by getFieldHelpers interface.
Solution Add useMemo to cache these arrow functions. This won't change the function references as long as fieldName is not changed.
References https://github.com/jaredpalmer/formik/issues/3602