简体   繁体   English

从 react-phone-number-input 导入电话号码验证器时出错 npm package

[英]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.

相关问题 如何限制 npm react-phone-number-input 包中的国家/地区列表 - How to limited the countries list in npm react-phone-number-input package 反应电话号码输入验证失败 - react-phone-number-input validation failure 如何使用 react-phone-number-input 库与 Formik 成为朋友? - How to friend Formik with react-phone-number-input lib? 如何使用Yarn安装react-phone-number-input? - How to install react-phone-number-input with Yarn? "没有国家选择器的 react-phone-number-input" - react-phone-number-input without the country selector 如何使用 react-phone-number-input 插入数据?,插入电话号码时出现验证错误 - How can I insert a data using react-phone-number-input?, validation error when I'm inserting a phone number 使用反应电话号码输入时如何为电话输入的边框颜色设置无 - How to set none for border color of the phone input when using react-phone-number-input React-Phone-Number-Input + React-Hook-Form:如何在控制器验证中获取当前国家代码? - React-Phone-Number-Input + React-Hook-Form: How to get current country code in controller validation? 当您尝试在 PhoneInput(React 和 React-phone-number-input)键入内容时,弹出窗口会自行关闭 - Popup closes byself when you try to type something at PhoneInput (React and React-phone-number-input) 如何将 react-phone-number-input 与 Formik 的 Field 组件一起使用 - How to use react-phone-number-input with Formik's Field component
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM