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

Compatibility with Shadcn #120

Open
vanities opened this issue Nov 4, 2024 · 3 comments
Open

Compatibility with Shadcn #120

vanities opened this issue Nov 4, 2024 · 3 comments

Comments

@vanities
Copy link

vanities commented Nov 4, 2024

Does this package have compatibility with shadcn? I was looking through the issues, but didn't see anything regarding that.

For example, something like this:

import {
  Form,
  FormControl,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "~/components/ui/form";

...
            <Form {...form}>
              <form
                onSubmit={form.handleSubmit}
                method="POST"
                className="space-y-6"
              >
...

etc. gives the error:

Type '{ children: Element; handleSubmit: (e?: any) => Promise<void>; reset: (values?: { otp: string; } | { otp?: string | undefined; } | undefined, options?: Partial<{ keepDirtyValues: boolean; ... 9 more ...; keepSubmitCount: boolean; }> | undefined) => void; ... 12 more ...; setFocus: UseFormSetFocus<...>; }' is not assignable to type 'UseFormReturn<{ otp: string; }, any, undefined>'.
  The types returned by 'handleSubmit(...)' are incompatible between these types.
    Type 'Promise<void>' is not assignable to type '(e?: any) => Promise<void>'.
      Type 'Promise<void>' provides no match for the signature '(e?: any): Promise<void>'.

It's probably that I'm misusing this library.

@ArvidAnderson
Copy link

From my experience, basic components like Input and Select from shadcn/ui work fine, but you can't use their specific form components as shown in your snippet. I've had success following the Remix hook form documentation instead of using shadcn/ui's form components directly.

@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

@genox
Copy link

genox commented Nov 10, 2024

I followed the example you posted but I can't get regular shadcn errors to show, the form always tries to show native form validation errors. Do you know how to disable this behaviour @Sutikshan ?

I set shouldUseNativeValidation: false, but this seems to have no effect.

edit: Nevermind, the issue was that I tried to be DRY and wrap the shad components to have less duplication but I guess that context gets lots along the way.

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

4 participants