import { useFormContext, Controller } from 'react-hook-form'; // @mui import TextField, { TextFieldProps } from '@mui/material/TextField'; // ---------------------------------------------------------------------- type Props = TextFieldProps & { name: string; }; export default function RHFTextField({ name, helperText, type, ...other }: Props) { const { control } = useFormContext(); return ( ( { if (type === 'number') { field.onChange(Number(event.target.value)); } else { field.onChange(event.target.value); } }} error={!!error} helperText={error ? error?.message : helperText} {...other} /> )} /> ); }