JSPM

formik-error-focus

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

Scroll to the first error in your Formik form and set focus

Package Exports

  • formik-error-focus

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 (formik-error-focus) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

formik-error-focus

package version package downloads standard-readme compliant package license make a pull request

Scroll to the first error in your Formik form and set focus

Table of Contents

About

Wrapper around scroll-to-element that scrolls to the first error element in Formik.

Usage

import React from 'react'
import { Formik, Field, Form } from 'formik'
import FormikErrorFocus from 'formik-error-focus'

export const Signup = () =>
  <div>
    <h1>My Uncool Persisted Form</h1>
    <Formik
      onSubmit={values => console.log(values)}
      initialValues={{ firstName: '', lastName: '', email: '' }}
      render={props =>
        <Form className="whatever">
          <Field name="firstName" placeholder="First Name" />
          <Field name="lastName" placeholder="Last Name" />
          <Field name="email" type="email" placeholder="Email Address" />
          <button type="submit">Submit</button>
          <FormikErrorFocus
            // See scroll-to-element for configuration options: https://www.npmjs.com/package/scroll-to-element
            offset={0}
            align={'top'}
            focusDelay={200}
            ease={'linear'}
            duration={1000}
          />
        </Form>}
    />
  </div>;

Install

This project uses node and npm.

$ npm install formik-error-focus
$ # OR
$ yarn add formik-error-focus

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT © Tiaan du Plessis