import { DisplayError } from 'components' import { useController } from 'react-hook-form' export default function TextField(props) { //? Props const { label, errors, name, type = 'text', control, direction, ...inputProps } = props //? Form Hook const { field } = useController({ name, control, rules: { required: true } }) //? Handlers const onChangeHandler = e => { const inputValue = e.target.value if (type === 'number' && inputValue.length !== 0) { field.onChange(parseInt(inputValue)) } else { field.onChange(inputValue) } } //? Render(s) return (
{label && ( )}
) }