Skip to content

Commit

Permalink
Fix use event callback in handlers (#2187)
Browse files Browse the repository at this point in the history
  • Loading branch information
deini authored and jaredpalmer committed Jan 9, 2020
1 parent 6f4aadd commit c959f47
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/formik/src/Formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ export function useFormik<Values extends FormikValues = FormikValues>({
[setFieldValue, state.values]
);

const handleChange = React.useCallback(
const handleChange = useEventCallback(
(
eventOrPath: string | React.ChangeEvent<any>
): void | ((eventOrTextValue: string | React.ChangeEvent<any>) => void) => {
Expand All @@ -635,7 +635,6 @@ export function useFormik<Values extends FormikValues = FormikValues>({
executeChange(eventOrPath);
}
},
[executeChange]
);

const setFieldTouched = useEventCallback(
Expand Down Expand Up @@ -676,15 +675,14 @@ export function useFormik<Values extends FormikValues = FormikValues>({
[setFieldTouched]
);

const handleBlur = React.useCallback(
const handleBlur = useEventCallback(
(eventOrString: any): void | ((e: any) => void) => {
if (isString(eventOrString)) {
return event => executeBlur(event, eventOrString);
} else {
executeBlur(eventOrString);
}
},
[executeBlur]
);

const setFormikState = React.useCallback(
Expand Down

1 comment on commit c959f47

@vercel
Copy link

@vercel vercel bot commented on c959f47 Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.