@@ -417,7 +417,12 @@ export function useFormik<Values extends FormikValues = FormikValues>({
417417 dispatchFn ( ) ;
418418 }
419419 } ,
420- [ props . initialErrors , props . initialStatus , props . initialTouched , props . onReset ]
420+ [
421+ props . initialErrors ,
422+ props . initialStatus ,
423+ props . initialTouched ,
424+ props . onReset ,
425+ ]
421426 ) ;
422427
423428 React . useEffect ( ( ) => {
@@ -548,7 +553,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
548553 const willValidate =
549554 shouldValidate === undefined ? validateOnBlur : shouldValidate ;
550555 return willValidate
551- ? validateFormWithHighPriority ( state . values )
556+ ? validateFormWithHighPriority ( stateRef . current . values )
552557 : Promise . resolve ( ) ;
553558 }
554559 ) ;
@@ -559,7 +564,9 @@ export function useFormik<Values extends FormikValues = FormikValues>({
559564
560565 const setValues = useEventCallback (
561566 ( values : React . SetStateAction < Values > , shouldValidate ?: boolean ) => {
562- const resolvedValues = isFunction ( values ) ? values ( state . values ) : values ;
567+ const resolvedValues = isFunction ( values )
568+ ? values ( stateRef . current . values )
569+ : values ;
563570
564571 dispatch ( { type : 'SET_VALUES' , payload : resolvedValues } ) ;
565572 const willValidate =
@@ -592,7 +599,9 @@ export function useFormik<Values extends FormikValues = FormikValues>({
592599 const willValidate =
593600 shouldValidate === undefined ? validateOnChange : shouldValidate ;
594601 return willValidate
595- ? validateFormWithHighPriority ( setIn ( state . values , field , value ) )
602+ ? validateFormWithHighPriority (
603+ setIn ( stateRef . current . values , field , value )
604+ )
596605 : Promise . resolve ( ) ;
597606 }
598607 ) ;
@@ -677,7 +686,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
677686 const willValidate =
678687 shouldValidate === undefined ? validateOnBlur : shouldValidate ;
679688 return willValidate
680- ? validateFormWithHighPriority ( state . values )
689+ ? validateFormWithHighPriority ( stateRef . current . values )
681690 : Promise . resolve ( ) ;
682691 }
683692 ) ;
0 commit comments