v2.2.0 (2022-09-12)
Additions:
- Add support for persisting state #12
Merged pull requests:
- Update docs dependencies #336 (andyrichardson)
- Add "fromState" to docs #335 (andyrichardson)
- Fix formatting #334 (andyrichardson)
- Move to Github Actions #333 (andyrichardson)
- Fix e2e tests #321 (andyrichardson)
- Add value restoration (optional) #320 (andyrichardson)
v2.1.1 (2021-11-02)
Closed issues:
- useLayoutEffect warning when server side rendering #317
Merged pull requests:
- Fix next.js support #318 (andyrichardson)
- Update dev deps #302 (andyrichardson)
2.1.0 (2021-01-13)
Additions:
- Add preact support #299
Merged pull requests:
- Add preact support #300 (andyrichardson)
That's right, a new major release jam packed full of new features and with a side helping of breaking changes.
Technically not part of this release but definitely worth a visit to check out the new guides!
Validation is now tailored to specific events (mount
, blur
, submit
, etc).
This provides extra flexibility to tweak validation for specific scenarios - such as triggering async validation only on submit (see example below).
useField({
validate: useCallback(({ trigger, value }) {
// Validation for all events
if (!value) {
throw Error("Value is required.");
}
// Validation for blur only events
if (trigger == "blur" && value.length < 4) {
throw Error("Value must be at least 4 characters.");
}
// Async validation only on submit
if (trigger == "submit") {
return serverSideValidation(value).then((isValid) => {
if (!isValid) {
throw Error("Server side validation failed");
}
});
}
}, [])
})
More info on event driven validation can be found here.
There's a new useSubmit
hook which:
- triggers the new
submit
validation event - aggregates field values into a single object
- tracks state of async submission validation
- guards submission logic until validation succeeds
const { isValidating, hasSubmitted, handleSubmit } = useSubmit(() => {
console.log('This is only called if submission validation succeeds!');
});
handleSubmit(); // Trigger submission
More info on submission can be found here.
initialValue
argument on theuseField
hook is now required (more info)validate
argument on theuseField
hook now receives only a single argument (more info)- removed deprecated properties
touched
andinitalTouched
on theuseField
hook (more info) - removed
initialValid
andinitialError
arguments on theuseField
hook in favor of validation events (more info) - removed
validateOnBlur
,validateOnChange
, andvalidateOnUpdate
arguments on theuseField
hook in favor of validation events (more info) - removed support for returning validation errors as strings without throwing (more info)
v1.3.1 (2020-07-30)
Fixed bugs:
- Changes to validation arg doesn't update validation function #235
Merged pull requests:
- Add setFieldState call to useField on validation change #278 (andyrichardson)
v1.3.0 (2020-06-14)
Additions:
- Add support for providing value to
onChange
#41 - Add support for React Native #35
- Add non DOM event support to onChange #123 (andyrichardson)
Closed issues:
Merged pull requests:
- Add native example #124 (andyrichardson)
- Update readme with video #122 (andyrichardson)
- Add e2e for example 3 #84 (andyrichardson)
- Add sitemap generation on build #83 (andyrichardson)
- Keep styling consistent between examples #48 (andyrichardson)
v1.2.1 (2020-02-25)
Fixed bugs:
- Duplicate field - add warning instead of error #45 (andyrichardson)
Closed issues:
- Add docs for
branching
#26
Merged pull requests:
- Add example branching #46 (andyrichardson)
v1.2.0 (2020-02-05)
Breaking changes:
- Revert checked state managment using ref #39
- Remove checkbox refs #40 (andyrichardson)
Additions:
- Add tracking of 'hasChanged' and 'hasBlurred' states #21
Merged pull requests:
- Use 'latest' tag for dependencies examples #43 (andyrichardson)
- Update checkbox docs #42 (andyrichardson)
- Add cypress integration #38 (andyrichardson)
- Add hasChanged and hasBlurred props to useField #37 (andyrichardson)
- Update examples #36 (andyrichardson)
v1.1.2 (2020-01-21)
Fixed bugs:
- Fix initial value for radio inputs #30
- Fix initial value for checkbox inputs #28
- Textarea onChange error #24
Closed issues:
- Add examples for validation and conditional rendering #33
- Add documentation for checkbox inputs #23
- Explain how to handle submission of field values #22
Merged pull requests:
- Add conditional examples for validation #34 (andyrichardson)
- Add docs for radio / checkbox usage #32 (andyrichardson)
- Fix radio input #31 (andyrichardson)
- Add mutation of checkbox element on ref and value change #29 (andyrichardson)
- Add textarea support #27 (andyrichardson)
v1.1.1 (2020-01-10)
Fixed bugs:
- Handle destroy on unmount changing value #18
Merged pull requests:
- Update deps #20 (andyrichardson)
- Add detection for destroyOnUnmount change #19 (andyrichardson)
v1.1.0 (2020-01-09)
Breaking changes:
- Fields without validation should be valid by default #11
Closed issues:
- Add docs #4
Merged pull requests:
- Setup linting #16 (andyrichardson)
- Default to valid when no validation is set #15 (andyrichardson)
- Add docs #5 (andyrichardson)
v1.0.3 (2019-12-22)
Fixed bugs:
Closed issues:
- Remove unnecessary dependency "react-dom" #8
Merged pull requests:
- Changelog guide + version bump #10 (andyrichardson)
- Remove react-dom #9 (andyrichardson)
- Fix checkbox issue #7 (andyrichardson)
- Remove
;
#2 (jontansey)