๐ React Hooks for form state management and validation (Web + React Native)
MIT License
Bot releases are visible (Hide)
Published by bluebill1049 over 4 years ago
๐ fix #1172 issue around remove with useFieldArray (#1173)
โค๏ธ improve types of Controller's onChange and onBlur (#1169)
Published by bluebill1049 over 4 years ago
๐ fix #1167 issue around watch multiple values with array (#1168)
Published by bluebill1049 over 4 years ago
Breaking change on Controller
Controller: onChange
will only evaluate payload as event
like object
. eg: react-select will no longer need the extra onChange
method at Controller
.
Before:
import { TextInput } from 'react-native';
<Controller
as={<TextInput style={{ borderWidth: 2, borderColor: 'black'}} />}
name="text"
control={args => ({
value: args[0].nativeEvent.text,
})}
onChange={onChange}
/>
now:
import { TextInput } from 'react-native';
<Controller
as={<TextInput style={{ borderWidth: 2, borderColor: 'black'}} />}
name="text"
control={args => args[0].nativeEvent.text}
onChange={onChange}
/>
Published by bluebill1049 over 4 years ago
Happy 1st birthday!
๐ fix validationResolver issue due to cache validationContext (#1132)
๐ improve useFieldArray with useCallback for each methods (#1130)
๐ fix #1141 getValues return empty string (#1145)
๐ Add UMD build target (#1157)
๐ fix #1158 fix setValue not working with object array (#1160)
๐ fix #1154 controller onChange type check (#1162)
Important: The above is a breaking change, which I will release a major version by today. Controller
: onChange
will only evaluate payload as event like object
. eg: react-select
will no longer need extra onChange
method at Controller
.
Published by bluebill1049 over 4 years ago
๐ fix #1123 issue on radio input reference remove (#1124)
Published by bluebill1049 over 4 years ago
๐ support multiple setValues (#1056)
๐ close #1097 issue with useFieldArray formState (#1111)
๐ update ControllerProps type to improve DX (#217)
๐ improve DX of register function (#1106)
๐ fix useFieldArray remove item error's order (#1103)
๐ fix useFieldArray clear error issue (#1099)
๐ fix #1094 Controller with SSR (#1095)
โณ๏ธ close #1090 controller get value (#1092)
๐ fix #1086 issue with watch re-render caused by dirty attribute (#1087)
Published by bluebill1049 over 4 years ago
๐support IE11 (#1063)
๐fix #1069 controller reset issue (#1071)
Note: inline defaultValue will overwrite data at Controller's defaultValues
๐ฟclose #1060 support value as true/false for required validation rule
๐ข throw error when formContext is missing (#1054)
Published by bluebill1049 over 4 years ago
๐ fix #1062 re-render issue with useFieldArray (#1064)
โฉ fix children prop type for ErrorMessage component (#1059)
Published by bluebill1049 over 4 years ago
๐ญrevert IE 11 bundle changes
Published by bluebill1049 over 4 years ago
๐ fix a bug reported at Spectrum around useEffect dependency: https://spectrum.chat/react-hook-form/help/after-update-4-9-3-to-4-9-4-formstate-isvalid-doesnt-work-properly~4fb3cd7f-3a74-4478-9ce2-4f029d8cb26c
Published by bluebill1049 over 4 years ago
๐ fix #1036 check watch input against name
๐ซ fix/watch use field array (#1036)
๐ fix #1026 around build-in isValid with useFieldArray (#1034)
โฉ fix #1033 props type for ErrorMessage
๐ add ts-polyfill to solve ie11 issues (#1018)
๐ fix #1007 reset with react native
๐ fix #1020 issue around watch undefined input (#1023)
๐ fix type for validationResolver (#1017)
โ๏ธ improve unset method (#1015)
Published by bluebill1049 over 4 years ago
๐ fix #1007 with Node Type check
๐ close #992 setValue with null and undefined (#1006)
Published by bluebill1049 over 4 years ago
๐ฎ feature/support custom schema validation (#974)
import React from "react";
import { useForm } from "react-hook-form";
import Joi from "@hapi/joi";
const validationSchema = Joi.object({
username: Joi.string().required()
});
const resolver = (data: any, validationContext) => {
const { error, value: values } = validationSchema.validate(data, {
abortEarly: false
});
return {
values: error ? {} : values,
errors: error
? error.details.reduce((previous, currentError) => {
return {
...previous,
[currentError.path[0]]: currentError
};
}, {})
: {}
};
};
export default function App() {
const { register, handleSubmit, errors } = useForm({
validationResolver: resolver,
validationContext: { test: "test" }
});
return (
<form onSubmit={handleSubmit(d => console.log(d))}>
<input type="text" name="username" ref={register} />
<input type="submit" />
</form>
);
}
๐ close #954 fix type for ErrorMessage component props (#966)
๐ fix #967 issue around getValues with defaultValues (#968)
๐ fix #969 fields compare function
โ๏ธ close #951 include keyName prop for custom id (#957)
โ๐ป improve type keyName for useFieldArray (#983)
๐จ๐ปโ๐ป improve type for ref (#990)
๐ fix #988 isValid form state with useFieldArray schema (#991)
โ fix #994 prevent useFieldArray items unregister (#995)
โจ๏ธ useFieldArray remove method support array of indexes (#980)
support remove([1,2,3])
Published by bluebill1049 over 4 years ago
๐fix issue around watch
API with nest set to true
Published by bluebill1049 over 4 years ago
๐ fix #670 reset empties the input
๐ fix #956 react native FileList not defined
๐ fix #955 field array dirty value compare
๐ Remove deprecated field from options type. (#952)
Published by bluebill1049 over 4 years ago
๐ close #938 performance enhancement for watch (#939)
๐บ improve #938 watch perf with search array (#946)
๐จโ๐ fix #932 issue around delete file list object in FF (#944)
๐ support rest props for ErrorMessage component (#941)
<ErrorMessage className="test" onClick={() => {}} errors={errors} name="test" />
โ๏ธ assign non-object values to value property (#940)
๐ fix mutationWatcher in remove event listener function
๐ค #924 improvement over watch with field array (#930)
Published by bluebill1049 over 4 years ago
๐จ๐ปโ๐ป get watch()
API to work with FieldArray
๐จ๐ปโ๐ป fix errors
and touched
fields position with useFieldArray
Published by bluebill1049 over 4 years ago
๐ fix #927 formState read flag (#929)
๐ฅ support register method with optional first argument for useFieldArray
๐ฅ add support for array values in useFieldArray methods (#925)
๐ฅ ErrorMessage
support message
prop
eg:
<ErrorMessage errors={errors} name="test" message="message here" />
Published by bluebill1049 over 4 years ago
๐ patch on remove api with last item (#909)
Published by bluebill1049 over 4 years ago
๐ญ fix useFieldArray
(#896)
register
without validation you will have to use register({})
to trigger ref
callbackmapID
of each renderreset
with dirty value๐ fix #903 errors type object comparison (#907)
๐ fix(Controller): Invoke onBlur
method when mode
is onBlur
. (#902)
๐ fix #890 radio dynamic inject issue (#901)
๐ fix #893 trigger validation (#900)
๐ fix #881 issue around formState with reset (#891)
๐ make handleSubmit event optional (#885)