-
-
Notifications
You must be signed in to change notification settings - Fork 278
useWatch selector init #762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
27328cb
1c2a469
673536c
250a65a
182e169
1a98550
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,9 @@ function useWatch( | |
const options = isFormInstance(_form) ? { form: _form } : _form; | ||
const form = options.form; | ||
|
||
const [value, setValue] = useState<any>(); | ||
const [value, setValue] = useState<any>( | ||
typeof dependencies === 'function' ? dependencies({}) : undefined, | ||
crazyair marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
||
|
||
const valueStr = useMemo(() => stringify(value), [value]); | ||
const valueStrRef = useRef(valueStr); | ||
|
@@ -117,8 +119,8 @@ function useWatch( | |
// ============================= Update ============================= | ||
const triggerUpdate = useEvent((values?: any, allValues?: any) => { | ||
const watchValue = options.preserve | ||
? (allValues ?? getFieldsValue(true)) | ||
: (values ?? getFieldsValue()); | ||
? allValues ?? getFieldsValue(true) | ||
: values ?? getFieldsValue(); | ||
|
||
const nextValue = | ||
typeof dependencies === 'function' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best to remove
console.log
statements from the code, even in examples, to keep it clean and avoid potential noise in browser consoles for users of the documentation.