From e50040abe49cf7bb46580ea46af6a2b487539830 Mon Sep 17 00:00:00 2001 From: Jinma Yamashita Date: Fri, 18 Dec 2020 08:51:28 +0900 Subject: [PATCH] Fix condition of calling getSelectedValues (#2881) Resolves - https://github.com/formium/formik/issues/2657 Prevent calling getSelectedValues when the element has not options. (e.g. input type is email with multiple) --- .changeset/brown-jokes-act.md | 5 +++++ packages/formik/src/Formik.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/brown-jokes-act.md diff --git a/.changeset/brown-jokes-act.md b/.changeset/brown-jokes-act.md new file mode 100644 index 000000000..67ee8eb03 --- /dev/null +++ b/.changeset/brown-jokes-act.md @@ -0,0 +1,5 @@ +--- +'formik': patch +--- + +Prevent calling getSelectedValues when the element has not options diff --git a/packages/formik/src/Formik.tsx b/packages/formik/src/Formik.tsx index 5c4ef7ee5..02934fa90 100755 --- a/packages/formik/src/Formik.tsx +++ b/packages/formik/src/Formik.tsx @@ -632,7 +632,7 @@ export function useFormik({ ? ((parsed = parseFloat(value)), isNaN(parsed) ? '' : parsed) : /checkbox/.test(type) // checkboxes ? getValueForCheckbox(getIn(state.values, field!), checked, value) - : !!multiple // ? getSelectedValues(options) : value; }