score:11

Accepted answer

You can use Formik's built in setFieldValue function to define your own change handler for the input which will set the number value directly:

           <InputNumber
                    id={count}
                    name={count}
                    type={"number"}
                    onChange={v => {
                      props.setFieldValue(count, v);
                    }}
                    onBlur={props.handleBlur}
                    defaultValue={props.initialValues[count]}
                    placeholder="Count"
                  />

According to the docs it also has a third boolean argument to determine whether or not to run validation. So passing in true after v should trigger validation if validateOnChange is enabled on the main Formik component.

score:1

Im not familiar with antd, but what i see is that when i change InputNumber to Input it works.

Basically, InputNumber is giving you the value back instead of the object like Input.

From antd docs:

Input -> onChange -> function(e) which is the SyntheticEvent

InputNumber -> onChange -> function(value: number | string) just a value


Related Query

More Query from same tag