JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 656
  • Score
    100M100P100Q109610F
  • License MIT

Submit errors helper for final-form

Package Exports

  • final-form-submit-errors

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (final-form-submit-errors) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

final-form-submit-errors

A helper for react-final-form which enables automatic submit errors reset

Reason

final-form is a great library, but it has one major problem. After you throw a submit error, your form becomes invalid forever and submit errors would not be cleared until the next submit.

It's very intuitive to clear an error if the field containing the error is changing. And final-form-submit-errors does exactly that.

Usage

import { Form } from 'react-final-form';
import { submitErrorsMutators, SubmitErrorsSpy } from 'final-form-submit-errors';

const MyForm = () => (
    <Form
        onSubmit={onSubmit}
        mutators={{
            // add submitErrorsMutators to your mutators
            ...submitErrorsMutators,
        }}
        render={({ handleSubmit }) => (
            <form onSubmit={handleSubmit}>
                {/* add SubmitErrorsSpy somewhere in your form */}
                <SubmitErrorsSpy />
            </form>
        )}
    />
);

License

MIT. Copyright (c) Anton Ignatev.