Skip to content

Commit

Permalink
Feature: added a useClearErrors hook.
Browse files Browse the repository at this point in the history
It can be used to reset the errors when a form is displayed again.
This way the errors to not linger around when the user navigates away
and back to the form.

Minor changes:

  1. Updated to TypeScript 3.6.3
  2. Locked dev dependencies.
  3. Made husky and lint-stage actually work.
  4. Ran `npm audit fix`
  • Loading branch information
MrHus committed Sep 20, 2019
1 parent accc968 commit 60c7169
Show file tree
Hide file tree
Showing 7 changed files with 916 additions and 105 deletions.
12 changes: 12 additions & 0 deletions docs/introduction/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ function Form() {
}
```

The above situation can also be achieved by using the `useClearErrors`
hook, which simply calls the `useEffect` for you.

```js
import React, { useEffect } from 'react';
import { useClearErrors } from '@42.nl/react-error-store';

function Form() {
useClearErrors();
}
```

### Clearing specific errors for a field

You can reset an error by calling `clearErrorsForValidator`:
Expand Down
Loading

0 comments on commit 60c7169

Please sign in to comment.