form
form copied to clipboard
[Feature Request]: useField instance returns label component.
It'd be nice if useField could optionally return a FieldLabel component that references the field with htmlFor automatically. FieldLabel would render a <label> element. The field would need to set its id attribute for htmlFor as well. Perhaps it could use the field path?
const {
FieldLabel,
meta: { error, isTouched, isValidating },
getInputProps
} = useField(field, fieldOptions);
return (
<>
<FieldLabel />
<input {...getInputProps()} />
</>
);