Warning message for undefined defaultValue #2797
Replies: 6 comments 5 replies
-
defaultValue shouldn't be |
Beta Was this translation helpful? Give feedback.
-
I also intentionally use undefined as defaultValue. Are there any other workarounds? |
Beta Was this translation helpful? Give feedback.
-
I also find this quite a troublesome issue. It will be much friendlier to use if the library does not impose a requirement that all fields must have a default, and just default the initial value to 'undefined' as the default if the node is not found in the defaultValue tree. |
Beta Was this translation helpful? Give feedback.
-
Since this discussion has been gaining some traction, I thought I'd unmark the answer. I've personally been trying to avoid the warning messages by using null but I've found it more of a chore than anything. |
Beta Was this translation helpful? Give feedback.
-
any updates on this issue? undefined still seams to cause problems |
Beta Was this translation helpful? Give feedback.
-
Still quite a problem. We shouldn't force forms to have valid values at first render. It makes sense to begin the form in an invalid state, then let the user enter valid values. For TypeScript users, at least we don't get a type error. For instance, I have a component to handle a form, which receives |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
In #2717, a warning message was added to
controller.tsx
for missingdefaultValue
.For me, there has been a flood of warning messages since I updated react-hook-form because the components I am using accepts
undefined
as "empty".To expand on my use-case, sometimes I only populate a default value if a preference setting is true:
Can we find a way to mute such a warning message?
Beta Was this translation helpful? Give feedback.
All reactions