UseFormUnregister
Unregister a field reference and remove its value.
@example
register("name", { required: true })
<button onClick={() => unregister("name")} />
// there are various keep options to retain formState
<button onClick={() => unregister("name", { keepErrors: true })} />
type UseFormUnregister<TFieldValues extends FieldValues> = (name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[], options?: Omit<KeepStateOptions, "keepIsSubmitted" | "keepSubmitCount" | "keepValues" | "keepDefaultValues" | "keepErrors"> & {
keepValue?: boolean;
keepDefaultValue?: boolean;
keepError?: boolean;
}) => void;§Type Parameters
§
TFieldValues extends FieldValues
[src]§Type
§
(name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[], options?: Omit<KeepStateOptions, "keepIsSubmitted" | "keepSubmitCount" | "keepValues" | "keepDefaultValues" | "keepErrors"> & {
[src]keepValue?: boolean;
keepDefaultValue?: boolean;
keepError?: boolean;
}) => void