1.0.4 • Published 5 years ago

react-scroll-to-first-error v1.0.4

Weekly downloads
18
License
GPL-3.0
Repository
github
Last release
5 years ago

react-scroll-to-first-error

A react hook for doing scroll to an invalid input on onSubmit. Works with any standard form and with other libraries like material-ui

NPM JavaScript Style Guide

Install

npm install --save react-scroll-to-first-error

Usage

      import React, { useRef } from 'react'
      import useScrollToError from 'react-scroll-to-error'

      function App() {
        const formEl = useRef(null);

        useScrollToError(formEl);

        return (
          <div>
            <form ref={formEl} noValidate>
              <input type="text" name="name" id="name" required />
              <input type="text" name="phone" id="name" />
              {/* we force height here for testing purposes */}
              <div style={{ height: "100vh" }} />
              <button type="submit">Submit</button>
            </form>
          </div>
        );
        }

License

GPL-3.0 © dieguezz

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago