import { DeepMap, FieldError, FieldValues, Path, UseFormRegister } from "react-hook-form"; interface FieldProps { register: UseFormRegister; name: Path; placeholder: string; type: string; step?: string; required?: boolean; errors: Partial>; } const Field = ({ register, name, placeholder, type, step, required = false, errors }: FieldProps) => { const inputProps: { className: string; "aria-invalid"?: boolean } = { className: "form-control", }; if (errors[name]) { inputProps.className += " is-invalid"; inputProps["aria-invalid"] = true; } if (!errors[name]) { inputProps.className += " is-valid"; } return (
{errors[name] &&
{errors[name]?.message}
}
); } export default Field;