Skip to content
Discussion options

You must be logged in to vote

defaultValues are not a simple object on RHF side.
if you rewrite you BaseFormProps interface like this, it should work

import { FieldValues, useForm, UseFormProps } from "react-hook-form";

interface BaseFormProps<TFormValues extends FieldValues> {
  defaultValues: UseFormProps<TFormValues>["defaultValues"];
}

function BaseForm<TFormValues extends FieldValues>({
  defaultValues,
}: BaseFormProps<TFormValues>) {
  const { control, handleSubmit } = useForm<TFormValues>({ defaultValues }); 
}

However, if you creating BaseForm to isolate hook usage, i would advise to do smth like this, it will allow to pass any attribute of useForm as a prop to your BaseForm

type BaseFormProps<TFormValues …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by NiklasKappel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants