Skip to content

Commit b2ce295

Browse files
committed
Update changelog/readme/comments
1 parent b473cdb commit b2ce295

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGELOG.MD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.0.3
2+
3+
- why are badges so difficult to get right? fixing it for real this time
4+
- stop checking after first error encountered, return that
5+
16
# 1.0.2
27

38
- Another hack at badges, more tooling

readme.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<img src="https://img.shields.io/npm/v/@tswaters/react-form-validation" alt="npm version">
55
</a>
66
<a href="https://travis-ci.org/tswaters/react-form-validation/">
7-
<img src="https://img.shields.io/travis/tswaters/react-form-validation" alt="npm version">
7+
<img src="https://img.shields.io/travis/tswaters/react-form-validation" alt="build status">
88
</a>
99
<a href="https://coveralls.io/github/tswaters/react-form-validation">
10-
<img src="https://img.shields.io/coveralls/github/tswaters/react-form-validation" alt="npm version">
10+
<img src="https://img.shields.io/coveralls/github/tswaters/react-form-validation" alt="coverage">
1111
</a>
1212
<a href="https://github.com/tswaters/react-form-validation/blob/master/LICENSE">
13-
<img src="https://img.shields.io/npm/l/@tswaters/react-form-validation" alt="npm version">
13+
<img src="https://img.shields.io/npm/l/@tswaters/react-form-validation" alt="license (MIT)">
1414
</a>
1515

1616
The goal of this library is to implement the [Constraint Validation API](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-constraint-validation-api) in React while not getting in your way to do it.
@@ -42,7 +42,7 @@ These are wrappers around `<form/>` and `<input/select/textarea>` elements. Any
4242

4343
`Input` elements must be children of a `Form` element. Under the covers, this library uses context to keep track of all fields on the form and will validate all of them if the form is submitted.
4444

45-
A `Validator` component is also provided which attempts to make using the api a bit easier. This is a container element that uses a render prop which is called with `({ error, valid, invalid, validated })`. This routine recursively traverses any provided props to replace `input/select/textarea` elements with the exports from this library, so it will duplicate any work on the tree that react may have done on that JSX tree up to that point.
45+
A `Validator` component is also provided which attempts to make using the api a bit easier. This is a container element that uses a render prop which is called with `({ error, valid, invalid, validated })`. This routine recursively traverses any provided props to replace `input/select/textarea` elements with the exports from this library, so it will duplicate any work already done up to that point.
4646

4747
## api
4848

@@ -274,6 +274,12 @@ const ErrorDisplay = error => {
274274
275275
For custom error messages, `error.message` will be whatever you returned or threw back and the code will be `customError`
276276
277+
## Thoughts on Performance
278+
279+
- make sure the tree passed via `<Validator />` is pretty simple. Validator recursively traverses the tree and replaces html inputs with exports from this library.
280+
281+
- validation functions should be memoized lest any change invoke a re-render (wrap functions with `useCallback`, or an array of functions with `memo`)
282+
277283
## limitations / bugs
278284
279285
- only the first error for a given input element will be returned

src/form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Form = forwardRef(({ onSubmit, ...rest }, ref) => {
1515
const fields = useRef([])
1616

1717
/**
18-
* This is invoked from `useFormContext`
18+
* This is invoked from `useValidation`
1919
* Each element, as it's mounted, must register with us so we can do things with them
2020
* This happens in a `useEffect` - the disposable will call the unregister function.
2121
*/

0 commit comments

Comments
 (0)