๐ React Hooks for form state management and validation (Web + React Native)
MIT License
Bot releases are hidden (Show)
Published by bluebill1049 over 2 years ago
๐ฐ close #7593 regression on fieldarray controller
/useController
unmount with unregister
(#7596)
๐ฅธ fix type issue with getFieldState and useController (#7574)
Published by bluebill1049 almost 3 years ago
๐จ fix #7571 cloneObject with setValue passed argument (#7572)
๐ฆบ unstable _getFieldState
API for retrieve field level state (#7475)
๐ป fix build on Windows (#7532)
thanks to @felixschorer
Published by bluebill1049 almost 3 years ago
๐ง close #6425 memorise useController
prop: onChange
onBlur
and ref
(#7526)
๐ related #7521 include name check with resetField (#7521)
๐ช close #7518 making value update before custom onChange (#7519)
๐ fix #7256 setValue
with shouldDirty
and shouldTouch
combine not update state correctly (#7508)
Published by bluebill1049 almost 3 years ago
Happy new year 2022!
๐ป Feature/avoid omitting key name use field array (improve DX) (#7301)
const App = () => {
const { control, register, handleSubmit } = useForm<FormValues>({
defaultValues: {
test: [{id: 'UUID5678', test: 'data' }] // id will be remained as it match default keyName
}
});
const { fields, append } = useFieldArray({
control,
name: 'test',
});
return (
<form>
{fields.map((field, index) => {
return <input key={field.id} {...register(`test.${index}.test`)} />;
})}
<button
type={'button'}
onClick={() => {
append({
id: 'UUID1234', // id value will be remained as it match default keyName
test: '1234',
});
}}
>
append
</button>
</form>
);
};
๐ฒ apply useCallback
for callback function to improve perf (#7378)
๐ท test coverage for types (#7311)
๐ improve useFieldArray performance with separate id state (#7447)
๐ฉ close #6776 improve register to support shadow roots (#7400)
๐ fix type infer with UseFormHandleSubmit (#7405)
๐ remove resolutions dep and update packages (#7396)
๐ผ import type for utility
๐ฅ improve useFormState with mounted ref to skip update when hook is unmounted (#7489)
๐ช improve updateFieldArray batch update (#7477)
๐ชก revert #6834 clearError should not affect isValid (#7470)
thanks to @daisuke85a, @MichalTarasiuk, @adrianos10, @barrymay and @felixschorer!
Published by bluebill1049 almost 3 years ago
๐ improve useFieldArray
performance with separate id state (#7447)
๐ฉ close #6776 improve register to support shadow roots (#7400)
๐ fix type infer with UseFormHandleSubmit (#7405)
๐ remove resolutions dep and update packages (#7396)
๐ผ import type for utility
thanks to @MichalTarasiuk, @adrianos10 and @felixschorer
Published by bluebill1049 almost 3 years ago
๐ป Feature/avoid omitting key name use field array (improve DX) (#7301)
const App = () => {
const { control, register, handleSubmit } = useForm<FormValues>({
defaultValues: {
test: [{id: 'UUID5678', test: 'data' }] // id will be remained as it match default keyName
}
});
const { fields, append } = useFieldArray({
control,
name: 'test',
});
return (
<form>
{fields.map((field, index) => {
return <input key={field.id} {...register(`test.${index}.test`)} />;
})}
<button
type={'button'}
onClick={() => {
append({
id: 'UUID1234', // id value will be remained as it match default keyName
test: '1234',
});
}}
>
append
</button>
<button>submit</button>
</form>
);
};
๐ฒ apply useCallback for callback function to improve perf (#7378)
๐ท test coverage for types (#7311)
thanks to @felixschorer
Published by bluebill1049 almost 3 years ago
๐ณ fix: change type order to make typescript hints for watch available (#7353)
๐ close #7341 allow useWatch to fallback to defaultValue with undefined
(#7360)
๐ fix #7347 defaultValues
not populate with disabled input (#7359)
thanks to @pawk3k and @felixschorer
Published by bluebill1049 almost 3 years ago
โ๏ธ close #7348 avoid errors state update with replace
and update
API (#7349)
โจ๏ธ include UnpackNestedValue for reset values (#7286)
โจ๏ธ close #7338 update FieldNamesMarkedBoolean type to boolean instead of true (#7340)
Published by bluebill1049 almost 3 years ago
๐ฟ fix #7313 shouldUnregister
prop with useController
/controller
after unmount (#7317)
Published by bluebill1049 almost 3 years ago
๐ close #7293 with async useFieldArray reset (#7299)
Published by bluebill1049 almost 3 years ago
๐ fix #7282 async reset within onSubmit formState update (#7285)
Published by bluebill1049 almost 3 years ago
๐ฑ๏ธ improve dx with reset API within onSubmit or combined with other (#7274)
const onSubmit = (data) => {};
React.useEffect(() => {
if (formState.isSubmitSuccessful) {
reset({ something: '' });
}
}, [formState, reset]);
handleSubmit(onSubmit);
to
const onSubmit = (data) => {
setSubmittedData(data);
reset(data); // no longer need to have useEffect
};
handleSubmit(onSubmit);
๐ fix #7268 async reset API with useFieldArray (#7269)
๐๏ธ build(esm): Use explicit .mjs extension for ESM, with CJS interop (#7262)
huge thanks goes to @evocateur
Published by bluebill1049 almost 3 years ago
๐ beta: build(esm): Use explicit .mjs extension for ESM, with CJS interop
Published by bluebill1049 almost 3 years ago
Revert "๐๏ธ build(esm): Use explicit .mjs extension for ESM (#7244)"
thanks to @evocateur
Published by bluebill1049 almost 3 years ago
๐ช remove UnionLike type (#7187)
๐ useFieldArray deep nested object issue due to object reference (#7240)
๐๏ธ build(esm): Use explicit .mjs extension for ESM (#7244)
๐ฎ close #7231 set deep nested value with controlled input via setValue (#7232)
thanks to @evocateur
Published by bluebill1049 almost 3 years ago
๐ shouldUseNativeValidation
will inject native validation attributes into field which supports both client & server (#7207)
const { register } = useForm()
<input {...register('name', { required: true })} />
<input name="name" required /> // both client and server render
๐คฆ๐ปโโ๏ธ fix #2717 regression with async field array actions (#7218)
Published by bluebill1049 almost 3 years ago
๐ fix #7174 issue with empty errors object prevent submit
Published by bluebill1049 almost 3 years ago
Revert ๐ข fix #7149 Supporting Number Object comparison in deepEqual (#7150)
thanks to @barrymay
Published by bluebill1049 almost 3 years ago
๐ฉโ๐ฉโ๐งโ๐ง unify register
onChange
with useController
retrieve value (#7153)
๐ fix setCustomValidity typo (#7154)
๐ข fix #7149 Supporting Number Object comparison in deepEqual (#7150)
๐
prevent update input type with files (#7147)
โ๏ธ deprecate unset empty array function (#7120)
๐ fix #7109 issue with field array dirty fields (#7119)
thanks to @getTobiasNielsen @swapnilrohom @lxy-yz and @LucasLemanowicz
Published by bluebill1049 almost 3 years ago
๐ fix #7090 shallow clone for object has no prototype methods (#7096)
๐ฎโ๐จ revert module config (#7095)
๐ฆ change node engine to >= 12.0
thanks to @barrymay