🏁 Final Form Submit Listener 🧐
Decorator for 🏁 Final Form that will call provided callbacks when submission is attempted, succeeds, or fails.
Installation
npm install --save final-form final-form-submit-listener
or
yarn add final-form final-form-submit-listener
Usage
🏁 Final Form Usage
// Create Formconst form = // Create Decoratorconst decorator = // Decorate formconst undecorate = // Use form as normal
🏁 React Final Form Usage
const submitListener = ...<Form onSubmit=submit decorators= submitListener // <--------- 😎 validate=validate render= <form onSubmit=handleSubmit> ... inputs here ... </form> />
API
createDecorator: ({ beforeSubmit?: BeforeSubmit, afterSubmitSucceeded?: AfterSubmit, afterSubmitFailed?: AfterSubmit) => Decorator
A function that takes optional callback functions and provides a 🏁 Final Form Decorator
that will listen for submission events and call the callbacks.
Types
AfterSubmit: (form: FormApi) => void
A callback that is given the 🏁Final Form instance (FormApi
).
BeforeSubmit: (form: FormApi) => void | false
A callback that is given the 🏁Final Form instance (FormApi
). If it returns false
, the submission will be aborted, and none of the "after submit" callbacks will fire.