feat: useWatch support selector - #637
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #637 +/- ##
=======================================
Coverage 99.43% 99.43%
=======================================
Files 18 18
Lines 1236 1240 +4
Branches 283 285 +2
=======================================
+ Hits 1229 1233 +4
Misses 7 7 ☔ View full report in Codecov by Sentry. |
zombieJ
reviewed
Nov 30, 2023
|
|
||
| const cancelRegister = registerWatch((values, allValues) => { | ||
| const newValue = getValue(options.preserve ? allValues : values, namePathRef.current); | ||
| const _values = options.preserve ? allValues : values; |
zombieJ
reviewed
Nov 30, 2023
| options.preserve ? getFieldsValue(true) : getFieldsValue(), | ||
| namePathRef.current, | ||
| ); | ||
| const initialValue = |
crazyair
commented
Nov 30, 2023
| form?: TForm | WatchOptions<TForm>, | ||
| ): GetGeneric<TForm>; | ||
|
|
||
| function useWatch<TForm extends FormInstance, TSelected = unknown>( |
Contributor
Author
There was a problem hiding this comment.
因为用了 TSelected,所以不建议 const values = useWatch<{name?: string}>(values => xxx) 设置 stroe 类型方式
…into support-selector
zombieJ
reviewed
Nov 30, 2023
| const { getFieldsValue, getInternalHooks } = formInstance; | ||
| const { registerWatch } = getInternalHooks(HOOK_MARK); | ||
|
|
||
| const getNewValue = (values: any, allValues: any) => { |
crazyair
commented
Nov 30, 2023
| options.preserve ? getFieldsValue(true) : getFieldsValue(), | ||
| namePathRef.current, | ||
| ); | ||
| const initialValue = getWatchValue(getFieldsValue(), getFieldsValue(true)); |
Contributor
Author
There was a problem hiding this comment.
还记得 Form.List 下需要设置 getFieldsValue({ strict: true }) 吗,这个true跟strict不能同时设置,需要加个options.strict 吗
zombieJ
approved these changes
Nov 30, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC: ant-design/ant-design#46173