react-hook-form-error
v1.0.2
Published
React Hook Form error message component
Downloads
698
Readme
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].