React material-ui KeyboardDatePicker and Formik not working

Viewed 7636

I'm creating a form with material-ui and I'm using Formik and Yup for validation.

The TextField components work perfectly, however, the KeyboardDatePicker component presented the following error in the console

_onChange is not a function

and is now presenting

type is undefined.

Below is a cbs with the code. https://codesandbox.io/s/agitated-dust-wf6fn

2 Answers

you can use .setFieldValue to set value manually on onChange event.

 onChange={val => {
      console.log("___", val);
      formik.setFieldValue("dob", val);
 }} 

this method will work in any usecase.

Related