When using withFormik, the handleChange function is not called when passed in via props. However, the input onChange event will call a local change handler function.
handleChange function from props should be called
https://codesandbox.io/embed/withformik-codesandbox-template-xolcc
| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 1.5.8
| React | 16.8.6
| TypeScript |
| Browser |
| npm/Yarn |
| Operating System | macOS
This is happening to me as well using Field component
There are multiple issues going on in your sandbox. WithFormik HoC does not accept extra options, but the resulting component does accept extra _props_. However, you _cannot_ pass it a handleChange prop, because handleChange is replaced by formik's handleChange prop. Instead, you can pass a _different_ prop and use it as a change handler.
Sandbox example: https://codesandbox.io/s/withformik-codesandbox-template-j5ltm
The jist:
const MyEnhancedForm = withFormik({
mapPropsToValues: () => ({ name: "", foo: "" }),
handleSubmit: () => {}
})(Form);
const App = () => (
<div className="app">
<MyEnhancedForm
doChange={() => console.log("prop change handler called")}
/>
</div>
);
const Form = props => (
<form onSubmit={props.handleSubmit}>
Typing in this box should call onChange
<input
type="text"
onChange={props.doChange}
value={props.values.name}
name="name"
/>
<button type="submit">Submit</button>
<DisplayFormikState {...props} />
</form>
);
Most helpful comment
This is happening to me as well using Field component