📌  相关文章
📜  react-phone-number-input 以反应钩子形式返回消息 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:05.789000             🧑  作者: Mango

代码示例1
import React from "react";
import { useForm, Controller } from "react-hook-form";
import PhoneInput, { isValidPhoneNumber } from "react-phone-number-input";

import "react-phone-number-input/style.css";

const MyForm = () => {
  const {
    handleSubmit,
    formState: { errors },
    control
  } = useForm();


  const onSubmit = (data) => {
    console.log(data);
  };

  return (
    
isValidPhoneNumber(value) }} render={({ field: { onChange, value } }) => ( )} /> {errors["phone-input"] && (

Invalid Phone

)}
); }; export default MyForm;