๐ React Hooks for form state management and validation (Web + React Native)
MIT License
Bot releases are visible (Hide)
Published by bluebill1049 almost 3 years ago
๐ฅ revert #7016 and add type test coverage (#7082)
๐ซ close #7079 flush update at the field array level before app/form-level (#7080)
Published by bluebill1049 almost 3 years ago
โจ feature: useWatch/useFormState exact prop (#6983)
useWatch({
name: 'test.test',
exact: true,
});
useFormState({
name: 'test.test',
exact: true,
});
๐ณ close #7032 with stale onBlur value (#7078)
๐ฆ upgrade to ts 4.5.2 (#6944)
๐ remove early subscription (#7056)
๐ฆ chore: Modify package.json to include es6 imports (#7034)
๐๏ธ fix(package.json): add node requirement version (#7039)
thanks to @barrymay @neighborhood999 and @karanaditya993
Published by bluebill1049 almost 3 years ago
๐ fix #7031 fast refresh (#7035)
Published by bluebill1049 almost 3 years ago
๐
close #7023 issue with async useFieldArray actions (#7029)
๐๏ธ chore(useWatch): making the name a read-only array (#7016)
โจ๏ธ adds types for no supplied props argument (#7017)
๐คฆ๐ปโโ๏ธ close #7013 avoid shallow clone for the custom object (#7014)
thanks to @dborysov @sfrieson
Published by bluebill1049 almost 3 years ago
๐ fix #7011 reset API with shouldUnregister: true for controlled components (#7012)
Published by bluebill1049 almost 3 years ago
๐ fix #7009 fix fast refresh with controller (#7010)
๐๐ป close #7001 shouldUnregister: true with useController unmount defaultValue (#7008)
๐ง close #6994 issue with mutate original state with shouldUnreigster: true (#6998)
Published by bluebill1049 almost 3 years ago
๐ fix #6984 disabled input with register value (#6985)
๐คฒ close #6987 avoid shallow clone for object field (#6988)
Published by bluebill1049 almost 3 years ago
โจ feature: new resetField
API (#6891)
const { resetField } = useForm();
resetField('test')
resetField('test', {
keepError: true,
keepDirty: true,
keepTouched: true,
defaultValue: 'test1',
})
โฑ close #6966 improve trigger by avoiding additional validation invocation (#6967)
thanks to @barrymay and @kotarella1110
Published by bluebill1049 almost 3 years ago
๐ fix 6933 by revert FieldPathWithValue
type #6753 (#6934)
๐งข close #6928 prevent schema error before user's action (#6929)
thanks to @mnigh @kotarella1110 @barrymay
Published by bluebill1049 almost 3 years ago
โจ new resetField
API
const { resetField } = useForm();
resetField('test')
resetField('test', {
keepError: true,
keepDirty: true,
keepTouched: true,
defaultValue: 'test1',
})
๐งข close #6928 prevent schema error before user's action (#6929)
๐งนremove createSubscription
and createSubscriber
to reduce size (#6880)
โ๐ป improve react strict mode support with subscription
โ๐ป improve useController
by integrating with useWatch
โ๐ป package size-reduction (close to 1%)
โ๐ป internally removed skipEarlySubscription
Published by bluebill1049 almost 3 years ago
๐จโ๐จโ๐ฆ schema error parent level look up (#6869)
const validationSchema = object().shape({
questions: array()
.min(1, "Array cannot be empty")
.of(
object().shape({
text: string().required("Some text is required")
})
)
});
function App() {
const {
control,
formState: { errors },
register
} = useForm({
mode: "onChange",
resolver: yupResolver(validationSchema),
defaultValues: { questions: [ { text: 'test' } ] }
});
const { fields, remove } = useFieldArray({
control,
name: "questions",
});
console.log(errors);
return (
<form>
{fields.map((question, questionIndex) => (
<div key={question.key}>
<input {...register(`questions[${questionIndex}].text`)} />
<button type="button"
onClick={() => {
remove(questionIndex);
}}
>
Remove
</button>
</div>
))}
</form>
);
}
Codesandbox LInk: works with min length parent error object look up
๐ fix #6896 validation isValid mixed with schema result (#6901)
๐จ close #6899 trigger isolate render for targeted input name (#6900)
๐ close #6889 disable early subscription with useController
(#6890)
๐ fix #6792 reset with keepDefaultValues
(#6886)
โ change the subject from class to function base to improve readability and reduce the size (#6843)
๐๐ป make sure subscriptions get unsubscribed after unmount (#6873)
๐งป prevent error lookup with fields (#6871)
Revert "Revert "โจ Add support for generic components using `FieldPatโฆ (#6753)
type ExpectedType = { test: string };
const Generic = <FormValues extends FieldValues>({
name,
control,
}: {
name: FieldPathWithValue<FormValues, ExpectedType>;
control: Control<FormValues>;
}) => {
const {
field: { value, ...fieldProps },
} = useController<FormValues, ExpectedType>({
name,
control,
defaultValue: { test: 'value' },
});
return <input type="text" value={value.test} {...fieldProps} />;
};
๐ข fix #6856 regression on set input file list (#6861)
โจ๏ธ fix #6852 watch missing type with DeepPartial (#6854)
thanks to @kotarella1110
Published by bluebill1049 about 3 years ago
โจ enable sharing form sections between forms in typescript (#6807)
๐ fix #6834 clearErrors
not reset isValid formState
to true
โ ๏ธ close #6830 warning under strict mode with Controller formState update (#6832)
๐งช include test coverage #6826 (#6827)
โจ add TypeScript support for optional array fields (#6826)
๐ allow Jest VSCode extension to run successfully on startup (#6810)
thanks to @barrymay @LinusU and @SimonSelg
Published by bluebill1049 about 3 years ago
๐ฎโ๐จ fix setFocus
api issue #6804
โจ๏ธ close #6761 improve useWatch return array type (#6788)
Revert "๐งถ add support for extended generics in path type (#6762)" (#6802)
๐ fix #6792 reset keep defaultValues with useWatch return (#6794)
โก๏ธ upgrade eslint to 8.0 and other package (#6789)
Published by bluebill1049 about 3 years ago
๐ฆ close #6777 fall back to defaultValues
with shouldUnregister: true
with unmount fieldArray
(#6780)
๐งฏ change validation message in example code to match the rule better (#6781)
๐ณ rename document.contains to live function (#6778)
๐ fix 6764 reset with keepDefaultValues: true
with isDirty
and dirtyFields
(#6774)
๐ fix #6765 useFieldArray trigger validation by field name (#6768)
๐งถ add support for extended generics in path type (#6762)
๐ fix #6754 focus issue with radio and checkbox (#6755)
thanks to @RolkerMan @hpohlmeyer
Published by bluebill1049 about 3 years ago
โจ Add support for generic components using FieldPathWithValue
(#6562)
type ExpectedType = { test: string };
const Generic = <FormValues extends FieldValues>({
name,
control,
}: {
name: FieldPathWithValue<FormValues, ExpectedType>;
control: Control<FormValues>;
}) => {
const {
field: { value, ...fieldProps },
} = useController<FormValues, ExpectedType>({
name,
control,
defaultValue: { test: 'value' },
});
return <input type="text" value={value.test} {...fieldProps} />;
};
Published by bluebill1049 about 3 years ago
๐ fix #6748 skip clone object when object contains function nodes (#6749)
โฎ revert interface & mapped type update (#6747)
๐ fix #6736 custom onChange getting called on blur (#6746)
๐ fix #6731 subscription issue with unmount field array (#6732)
๐ simplify controller field state error type (#6730)
๐ improve reset with keepDefaultValues options (#6720)
๐ improve useSubscribe hook (#6724)
๐ more TS test coverage for missing generic at useForm (#6716)
thanks to @fzkirablackwhy @kotarella1110
Published by bluebill1049 about 3 years ago
Revert "โจ Add support for generic components using FieldPathWithValue
(#6562)" (#6717)
๐๏ธ fix Path and ArrayPath types for defined value type with interface (#6626)
๐ง close #6657 support equality check on date time object (#6706)
thanks to @kotarella1110 @jviall
Published by bluebill1049 about 3 years ago
โจ Add support for generic components using FieldPathWithValue
(#6562)
type ExpectedType = { test: string };
const Generic = <FormValues extends FieldValues>({
name,
control,
}: {
name: FieldPathWithValue<FormValues, ExpectedType>;
control: Control<FormValues>;
}) => {
const {
field: { value, ...fieldProps },
} = useController<FormValues, ExpectedType>({
name,
control,
defaultValue: { test: 'value' },
});
return <input type="text" value={value.test} {...fieldProps} />;
};
โ๏ธ migrate from Select.options to Select.selectedOptions (#6678) (#6687)
๐ fix #6683 trigger regression with isValid subscription (#6686)
Thanks to @julienfouilhe and @krnlde
Published by bluebill1049 about 3 years ago
โจ๏ธ fix field state error type with NestedValue (#6658)
๐ fix #6655 issue with field array focus name with filter operator (#6656)
๐ fix #6651 trigger api with schema validation per field level (#6652)
Thanks to @kotarella1110 @barrymay @nicholascm @fahadsohail482
Published by bluebill1049 about 3 years ago
๐น fix #6646 incorrect type with fieldState error (#6650)
๐ง refactor subscription logic into useSubscribe (#6614)
Thanks to @kotarella1110 @barrymay