You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if it a bug or a feature, but I have couple 3rd Party components that I had to wrap into controller and I was assuming making everything shiny and styled with useController, but problem came in my defaultValue.
I have pretty large form with ~20 inputs and some of them requires on render to be set as true or false
useController ignoring default value that was given in higher option of the useForm, but on the other hand Controller working as it should, even if the prop is overwritten or not given it still will default to prop that was passed to the controller itself. useController doesnt not take anything unless it is part it own eco system. I have even tried to use control from useFormContext I was assuming that is original issue that it could not subscribe but looks like it is an optional field per docs.
So returning to the original question is this a bug or does it should work this way, or there is alternative code to make it work and accept default values from useForm itself?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am not sure if it a bug or a feature, but I have couple 3rd Party components that I had to wrap into controller and I was assuming making everything shiny and styled with
useController
, but problem came in my defaultValue.I have pretty large form with ~20 inputs and some of them requires on render to be set as
true
orfalse
when I am using
Controller
even with defaultValue as a prop that comes from parent componentI will get an input with both scenario where on is false and one is true, but when I use
useController
useController
ignoring default value that was given in higher option of the useForm, but on the other handController
working as it should, even if the prop is overwritten or not given it still will default to prop that was passed to the controller itself. useController doesnt not take anything unless it is part it own eco system. I have even tried to use control fromuseFormContext
I was assuming that is original issue that it could not subscribe but looks like it is an optional field per docs.So returning to the original question is this a bug or does it should work this way, or there is alternative code to make it work and accept default values from
useForm
itself?Happy Coding!
Beta Was this translation helpful? Give feedback.
All reactions