[英]Getting an error while importing Phone number Validator from the react-phone-number-input npm package
I'm importing the phone number validator from the package into a checkout form on my page but it's showing this error when I refresh the page:我正在将电话号码验证器从 package 导入到我页面上的结帐表单中,但是当我刷新页面时它显示此错误:
"[libphonenumber-js]
metadata
argument was passed but it's not a valid metadata. Must be an object having.countries
child object property. Got an object of shape: { default }."“[libphonenumber-js]
metadata
参数已传递,但它不是有效的元数据。必须是具有.countries
子 object 属性的 object。得到形状为 object:{ default }。”
Here is the Code Block of the Phone Validator这是电话验证器的代码块
import React, {useState} from 'react'
import PhoneInput from 'react-phone-number-input'
function Phone() {
// `value` will be the parsed phone number in E.164 format.
// Example: "+12133734253".
const [value, setValue] = useState()
return (
<PhoneInput
placeholder="Enter phone number"
value={value}
onChange={setValue}/>
)
}
export default Phone
https://stackblitz.com/edit/react-eb2auu?file=src%2FWebpages%2FRegister.js,src%2FComponents%2FPhone.js,src%2FWebpages%2FCheckout.js https://stackblitz.com/edit/react-eb2auu?file=src%2FWebpages%2FRegister.js,src%2FComponents%2FPhone.js,src%2FWebpages%2FCheckout.js
^ This is a hosted version of the whole website/code. ^ 这是整个网站/代码的托管版本。
I've tried to use a simple input tag as shown in the npm package as well as importing the phone input from the package directly into the checkout file rather than making a separate component to import and render into the checkout form and all of them are returning the same error.我尝试使用一个简单的输入标签,如 npm package 所示,并将电话输入从 package 直接导入结帐文件,而不是制作一个单独的组件来导入和呈现到结帐表单中,所有这些都是返回相同的错误。
It seems to be an issue with the version of react-phone-number-input
, I downgraded to version 3.2.0
and the error is gone.好像是
react-phone-number-input
版本的问题,我降级到3.2.0
版本,报错没有了。
Gitlab Issue: [3.2.1] (React-Hook-Form) Error [libphonenumber-js] metadata
argument was passed but it's not a valid metadata. Gitlab 问题:[3.2.1] (React-Hook-Form) 错误 [libphonenumber-js]
metadata
参数已传递,但它不是有效的元数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.