Attempted import error : 'required' is not exported from 'yup'

Attempted import error : 'required' is not exported from 'yup'

大家好,我已经在我的新项目中安装了 yup,但是在导入它之后我收到了以下错误。要求不出口。我试图改变导入的位置,比如把它放在最上面,但仍然没有任何反应请帮助我必须在我的反应中添加验证 App.Thanks

我在我的应用程序中使用了以下库

"dependencies": {
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.24.0",
"bootstrap": "^4.6.0",
"datatables.net-bs4": "^1.11.3",
"date-fns": "^2.26.0",
"formik": "^2.2.9",
"jquery": "^3.6.0",
"react": "^17.0.2",
"react-bootstrap": "^2.0.2",
"react-day-picker": "^7.4.10",
"react-dom": "^17.0.2",
"react-router-dom": "^6.0.2",
"react-scripts": "4.0.3",
"react-toastify": "^8.1.0",
"react-tooltip": "^4.2.21",
"react-yup": "^1.23.0",
"web-vitals": "^1.0.1",
"yup": "^0.32.11"

},

您需要先使用 Yup.string()Yup.number() 等架构类型,然后才能使用 required()

只有模式有 required 属性:

BaseSchema, MixedSchema, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema

它不是直接从 Yup 导出的。