TanStackT
TanStack6mo ago
2 replies
faint-white

19 generics to FieldApi.. better alternatives for me?

I'm passing a field as prop to a reusable form component that is pretty lenghty and reusable in my forms (the component itself is about 400 lines and handles a lot of logic for setting open hour for a week).

Attempting for useField also is the same (19 generics), and not happy about receiving a form typed as ReturnType<typeof useForm<PlaceFormValues>> (ie: const field = useField({ form, name: 'openingHours' });).

For clarity, this is my current (pre updating to latest version):

interface DayOpeningHoursProps {
  field: FieldApi<
    PlaceFormValues,
    "openingHours",
    undefined,
    undefined,
    PlaceFormValues["openingHours"]
  >;
  day: keyof PlaceFormValues["openingHours"];
  merged?: boolean;
  split?: () => void;
}
Was this page helpful?