Why does the watch
function have a default value?
#12413
-
Why does the watch function have a default value?
It seems unnecessary since we can set default values with the defaultValues option in the useForm function.
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
It's only useful if you don't provide the default values when you call |
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. I provide default values in wath only, but I can't see default values in my form 🤔 |
Beta Was this translation helpful? Give feedback.
-
This is my sample component. I can't see 'Joshua' in my browser. I think default values in watch function is other meanings.
|
Beta Was this translation helpful? Give feedback.
-
Okay. I understand. Thank you for your response 😄 By the way, in what kind of program would you use default values? Do you have any knowledge of this? |
Beta Was this translation helpful? Give feedback.
I always provide the default values when calling
useForm()
for any form I am creating. This is the simplest method, and I recommend you try it. By doing this, I've never needed to provide a default value when usingwatch
. I think that's only useful if you're code can't handle having a value ofundefined
.