#Is there a hook that can tell if the "current" form is being submitted?
1 messages · Page 1 of 1 (latest)
Is there a hook that can tell if the "current" form is being submitted?
Can be achived by using a context wrapper. A good example of how such context can be implemented with ex. react-hook-forms, are available in shadcn-ui. - an easier approach, is to keep your button a pure component, and simply provide a "isSubmitting" prop, that also disables the button, and includes the correct aria attributes. 🙂
Shadnc-ui form: https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/form.tsx
React context: https://react.dev/reference/react/useContext
On keeping components pure: https://react.dev/learn/keeping-components-pure