vantezzen / auto-form

🌟 A React component that automatically creates a @shadcn/ui form based on a zod schema.
https://vantezzen.github.io/auto-form/
MIT License
2.76k stars 99 forks source link

Props must be serializable for client components #3

Closed thepeterkovacs closed 1 year ago

thepeterkovacs commented 1 year ago

This issue occurs in the date-picker ui component at the setDate prop when using it in Next.js 13.4.

"use client"
...
export function DatePicker({ date, setDate }: { date?: Date; setDate: (date?: Date) => void }) {
...

setDate can not be of type (date?: Date) => void

vantezzen commented 1 year ago

From what I can tell, it looks like serialization for the whole zod schema is problematic with server components. I tried using the SuperJSON plugin but that only throws other serialization errors.

For now, I would recommend using the AutoForm component inside a client component. If someone finds a way to enable using AutoForm in server components I'm happy to accept a PR!

raphaelmsr commented 5 months ago

Hey there! Would this help in anyway ? https://kitchen-sink.trpc.io/react-hook-form?file=feature%2Freact-hook-form%2Findex.tsx#content Just found that looking for options in zod's repo issues! Would gladly help