π Final Form decorator that provides callback hooks for submitting
npm install final-form-submit-listener




Decorator for π Final Form that
will call provided callbacks when submission is attempted, succeeds, or fails.
``bash`
npm install --save final-form final-form-submit-listener
or
`bash`
yarn add final-form final-form-submit-listener
`js
import { createForm } from 'final-form'
import createDecorator from 'final-form-submit-listener'
// Create Form
const form = createForm({ onSubmit })
// Create Decorator
const decorator = createDecorator()
// Decorate form
const undecorate = decorator(form)
// Use form as normal
`
`js
import React from 'react'
import { Form, Field } from 'react-final-form'
import createDecorator from 'final-form-submit-listener'
const submitListener = createDecorator({
beforeSubmit: formApi => { / do something before / },
afterSubmitSucceeded: formApi => { / do something on success / },
afterSubmitFailed: formApi => { / do something on fail / },
})
...
API
$3
A function that takes optional callback functions and provides a π Final Form
Decorator that will listen for submission events and call the callbacks.Types
$3
FormApi).$3
FormApi). If it returns false`, the submission will be aborted, and none of the "after submit" callbacks will fire.