import { Controller, useFormContext } from "react-hook-form"; import { PhoneInput } from "./phone-input"; import type { PhoneInputProps } from "."; // ---------------------------------------------------------------------- export type Props = Omit & { name: string; }; export default function RHFPhoneInput({ name, helperText, ...other }: Props) { const { control, setValue } = useFormContext(); return ( ( setValue(name, newValue, { shouldValidate: true }) } error={!!error} helperText={error ? error?.message : helperText} {...other} /> )} /> ); }