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
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
- Fork it and create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am "Add some feature"
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
License
MIT © Tiaan du Plessis