Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError with the control object #116

Open
WangHansen opened this issue Oct 19, 2024 · 1 comment
Open

TypeError with the control object #116

WangHansen opened this issue Oct 19, 2024 · 1 comment

Comments

@WangHansen
Copy link

Got:

Type 'Control<{ email: string; password: string; }, any>' is not assignable to type 'Control<{ email: string; password: string; }>'.
  Types of property '_updateFieldArray' are incompatible.
    Type 'import("/xxx/node_modules/react-hook-form/dist/types/form").BatchFieldArrayUpdate' is not assignable to type 'import("/xxx/node_modules/react-hook-form/dist/types/form").BatchFieldArrayUpdate'.
      Types of parameters 'updatedFieldArrayValues' and 'updatedFieldArrayValues' are incompatible.
        Type 'Partial<FieldArray<TFieldValues, TFieldArrayName>>[] | undefined' is not assignable to type 'Partial<FieldArray<TFieldValues, ArrayPath<TFieldValues>>>[] | undefined'.
          Type 'Partial<FieldArray<TFieldValues, TFieldArrayName>>[]' is not assignable to type 'Partial<FieldArray<TFieldValues, ArrayPath<TFieldValues>>>[]'.
            Type 'Partial<FieldArray<TFieldValues, TFieldArrayName>>' is not assignable to type 'Partial<FieldArray<TFieldValues, ArrayPath<TFieldValues>>>'.
              Type 'keyof FieldArray<TFieldValues, ArrayPath<TFieldValues>>' is not assignable to type 'keyof FieldArray<TFieldValues, TFieldArrayName>'.
                Type 'string | number | symbol' is not assignable to type 'keyof FieldArray<TFieldValues, TFieldArrayName>'.
                  Type 'string' is not assignable to type 'keyof FieldArray<TFieldValues, TFieldArrayName>'.
                    Type 'string' is not assignable to type 'never'.
                      Type 'keyof FieldArray<TFieldValues, ArrayPath<TFieldValues>>' is not assignable to type 'never'.
                        Type 'string | number | symbol' is not assignable to type 'never'.
                          Type 'string' is not assignable to type 'never'.ts(2322)

Code:

const schema = zod.object({
  email: zod.string().email().min(1),
  password: zod
    .string()
    .regex(/^(?=.*[A-Z])(?=.*[a-z])(?=.*d).+$/)
    .min(8),
});

export default function Login() {
  const {
    handleSubmit,
    formState: { errors },
    control,
  } = useRemixForm<zod.infer<typeof schema>>({
    mode: "onSubmit",
    resolver: zodResolver(schema),
  });

  return (
    <div>
      <Form onSubmit={handleSubmit} method="POST">
        <FormField
          control={control}
          name="email"
          render={({ field }) => (
            <FormItem>
              <FormLabel>Email</FormLabel>
              <FormControl>
                <Input placeholder="shadcn" {...field} />
              </FormControl>
              <FormMessage />
            </FormItem>
          )}
        />
      </Form>
    </div>
  );
}
@Sutikshan
Copy link

you may need to utilise RemixFormProvider .
example impl https://github.com/Sutikshan/tess-fs/blob/main/web/app/routes/provider.organization.tsx#L112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants