react-hook-form-error

React Hook Form error message component

Usage no npm install needed!

<script type="module">
  import reactHookFormError from 'https://cdn.skypack.dev/react-hook-form-error';
</script>

README

Performant, flexible and extensible forms with easy to use validation.

npm downloads npm npm Tweet Join the community on Spectrum

Install

$ npm install react-hook-form-error

Quickstart

import React from 'react';
import useForm from 'react-hook-form';
import { RHFError } from 'react-hook-form-error';

function App() {
  const { handleSubmit, register, errors } = useForm();

  return (
    <form onSubmit={handleSubmit(data => console.log(data))}>
      <input name="test" ref={register} />
      <RHFError name="test" errors={errors} />
      <button>submit</button>
    </form>
  );
}

API

Prop Type Required Default Description
name string Unique name to register the custom input
errors Object (optional when using errors) React Hook Form errors
as Component Component reference eg: <span />
messages Object keys of error type's message

Backers

Thank goes to all our backers! [Become a backer].

Contributors

Thanks goes to these wonderful people. [Become a contributor].