导入yup文件时白屏死机问题

问题描述 投票:0回答:0

我正在使用 react with formik 是的。我制作了这个 yp 模式文件,但我不知道为什么当我将它导入我的组件时,我的整个应用程序全是白屏。谁能找到解决我问题的方法。

index.js

import * as yup from "yup";

const emailRegExp =
  /^[^@\s]+@(?!.*(?:\.gmail|\.outlook)\.com)[^@\s]+\.[^@\s]+$/i;
const phoneRegExp =
  /^((\\+[1-9]{1,4}[ \\-]*)|(\\([0-9]{2,3}\\)[ \\-]*)|([0-9]{2,4})[ \\-]*)*?[0-9]{3,4}?[ \\-]*[0-9]{3,4}?$/;

export const basicSchema = yup.object().shape({
  firstname: yup
    .string()
    .firstname("Please fill in this field")
    .required("required"),
  lastname: yup
    .string()
    .lastname("Please fill in this field")
    .required("required"),
  email: yup
    .string()
    .email("Please fill in this field")
    .matches(emailRegExp, { message: "No personal email is allowed" })
    .required("required"),
  confirmEmail: yup
    .string()
    .oneOf([yup.ref("password"), null], "Email must match")
    .required("required"),
  company: yup
    .string()
    .company("Please fill in this field")
    .required("required"),
  jobTitle: yup
    .string()
    .jobTitle("Please fill in this field")
    .required("required"),
  phone: yup
    .string()
    .matches(phoneRegExp, "Phone number is not valid")
    .required("required"),
});

reactjs formik yup
© www.soinside.com 2019 - 2024. All rights reserved.