form icon indicating copy to clipboard operation
form copied to clipboard

[Feature Request]: useField instance returns label component.

Open smurrayatwork opened this issue 5 years ago • 0 comments

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()} />
  </>
);

smurrayatwork avatar Jun 24 '20 16:06 smurrayatwork