While react-hook-form
supports strong typing everywhere, including support for types inferred from a Yup schema (Yup.InferType<Schema>
), passing field names to controls is still untyped. However, this can be resolved with RHF's FieldPath
type and a helper function.
// Option 1: Declared per form, less boilerplate per control
export const getOrganizationFormField = (name: FieldPath<OrganizationForm>) => name;
getOrganizationFormField("billingAddress.address1");