github react-hook-form/react-hook-form v7.35.0-next.0
Version 7.35.0-next.0

latest releases: v7.52.0, v7.51.5, v7.51.4...
pre-release22 months ago

πŸŽ‰ feature: new type FieldPathByValue field path by value generic implementation

function SomeCustomFormComponent<
  TFieldValues extends FieldValues,
  Path extends FieldPathByValue<TFieldValues, Date>
>({ control, name }: { control: Control<FieldValues>; name: Path }) {
  const { field } = useController({
    control,
    name,
  });
  return null;
}

function ExampleOfUsage() {
  const { control } = useForm<{
    foo: Date;
    baz: string;
  }>();

  return (
    <div>
      <SomeCustomFormComponent control={control} name="foo" />{" "}
      {/* throw no error */}
      <SomeCustomFormComponent control={control} name="baz" />{" "}
      {/*  throw an error since baz is string */}
    </div>
  );
}

🐞 fix #8919 make useController fieldState properties enumerable

const { fieldState } = useController({ name: 'test' })
const copy = {...fieldState} βœ…

πŸ‘ΆπŸ» close #8909 form context children prop type (#8910)

<FormProvider {...methods}>
  <div /> // βœ…
  <div /> // βœ…
</FormProvider>

🐌 allow field errors to escape type check when provided with any type

thanks to @carvalheiro, @chetvishal and @MicaelRodrigues

Don't miss a new react-hook-form release

NewReleases is sending notifications on new releases.