-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create 2024-11-12-react-hook-form.md
- Loading branch information
1 parent
8f9b01b
commit c443261
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
1. `type=number|date` (validateAsNumber|validateAsDate) | ||
2. touched表示被触碰过, dirty表示和之前的value不一样(touchFields|dirtyFields|isDirty) | ||
3. mode: onSumit(default)|onTouched|onChange|all | ||
4. watch(value|[value]) 实时监听real-time-listening | ||
5. getField|setField | ||
6. phoneNumber: [1,2,3], phoneNumber.0, phoneNumber.1 | ||
7. soical{twitter, facebook}, social.twitter, social.facebook | ||
8. required, pattern, maxLength, minLength, max, min, validate: (value) => true|string | ||
9. `<form onSumbit={handleSubmit(onSumbit(data), onError(error))} noValidate>` | ||
10. control, react-hook-form dev tool | ||
11. formState: isValid|isDirty submit button | ||
12. register => name, value, onChange, onBlur | ||
13. `<DevTool control={control>` | ||
14. isSubmitting|isSubmitted|isSubmitSuccessful | ||
15. submitCount计算成功的次数 | ||
16. useWatch,需要包含在FormProvider或者传递control参数, 对于性能有帮助, 集中到component的re-render, 减少外部的re-render |