forge42dev / remix-hook-form

Open source wrapper for react-hook-form aimed at Remix.run
MIT License
354 stars 29 forks source link

Type mismatch #42

Closed adaboese closed 1 year ago

adaboese commented 1 year ago
Screenshot 2023-10-27 at 1 01 33 PM

I am not sure what's the problem here, but I am following the README.md.

import { z } from 'zod';

const FormDataZodSchema = z.object({
  action: z.string(),
  outline: z.string().min(2, {
    message: 'Outline must be at least 2 characters.',
  }),
});

type FormData = z.infer<typeof FormDataZodSchema>;

const resolver = zodResolver(FormDataZodSchema);

// ...

const form = useRemixForm<FormData>({
    defaultValues: {
      outline: articleProject.articleOutline ?? '',
    },
    mode: 'onSubmit',
    resolver,
  });

  useEffect(() => {
    if (generateOutlineFetcher.data?.outlineMarkdown) {
      form.setValue('outline', generateOutlineFetcher.data.outlineMarkdown);
    }
  }, [form, generateOutlineFetcher.data?.outlineMarkdown]);

  const actionIsPending = isGenerating;

  return (
    <RemixFormProvider {...form}>
      <Form
        className={css({
          display: 'flex',
          flexDir: 'column',
          gap: '8',
        })}
        onSubmit={form.handleSubmit}
      >
AlemTuzlak commented 1 year ago

I think I know what the issue is, will fix tomorrow

adaboese commented 1 year ago

Thank you!!!

AlemTuzlak commented 1 year ago

@adaboese fixed