vantezzen / auto-form

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

Expose formState for children as render prop #79

Closed LandSprutte closed 4 weeks ago

LandSprutte commented 4 weeks ago

Exposing the FormState as render props for children within the form, allowing you to view submission-state of the form and more ofc :)

e.g:

const RandomForm = () =>  { 
  return (
      <AutoForm ... >
        {({ isSubmitting }) => <SubmitButton pending={isSubmitting} />}
      </AutoForm>
    );
};

const SubmitButton = ({ pending }: { pending: boolean }) => {
  return (
    <Button disabled={pending} type="submit">
      {pending ? Please wait... :  Submit}
    </Button>
  );
};
vantezzen commented 4 weeks ago

Thank you for the contribution!