Formik and Yup : TypeError: Cannot read property 'object' of undefined
I had the same problem and then I realised I was using yup in the code instead of Yup. Below is the code sample and it works perfectly :)
import * as Yup from "yup";
const formSchema = Yup.object().shape({
email: Yup.string().required().email(),
password: Yup.string().required().min(6),
});
The correct answer is not to downgrade, but to change how you import it.
Try import * as Yup from 'yup'
instead of import Yup from 'yup'
.
// wrong
import Yup from 'yup';
// correct
import * as Yup from 'yup';
Here is your example working: https://codesandbox.io/s/xlnw2x0kk4.