π feature: new type FieldPathByValue
field path by value generic implementation
function SomeCustomFormComponent<
TFieldValues extends FieldValues,
TPath extends FieldPathByValue<TFieldValues, Date>
>({
control,
name
}: {
control: Control<TFieldValues>,
name: TPath
}) {
const { field } = useController({
control,
name,
});
return null;
}
function ExampleOfUsage () {
const {control} = useForm<{
foo: Date;
baz: string;
bar: {
baz: Date;
}
}>()
return <>
<SomeCustomFormComponent control={control} name="foo" /> {/* throw no error */}
<SomeCustomFormComponent control={control} name="baz" /> {/* throw an error since baz is string */}
</>;
}
π 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