RFC: making control object optional for all the hooks #7081
Replies: 3 comments
-
To be honest, I think it's a nice-to-have, considering the cons - 1) I'm curious how you know which useForm its related to (i guess you would infer it from the parent or registered child?) and 2) I like the fact that I know exactly what form things are tied to. |
Beta Was this translation helpful? Give feedback.
-
I personally don't really have a need for this. It's easy to add the |
Beta Was this translation helpful? Give feedback.
-
I realize that this is a bit of a stale discussion but it is relevant to my use case. We have a pretty large internal component library and many of our custom form controls are controlled. We would love to leverage It seems like this RFC would solve our problem. I don't think switching to uncontrolled components is feasible for us right now. Any recommendations on how to proceed? |
Beta Was this translation helpful? Give feedback.
-
Context
control
object is a requiredprop
for the following hooks.useController
useFormState
useFieldArray
useWatch
This is an internal object which provides a way for developers to avoid using
context
API (FormProvider). However, it does make component integration a bit harder, especially whencontrol
prop becomes a required prop and will result in run time error without such. I would like to purposecontrol
object to be optional, so developers can integrate with those hooks without worrying aboutcontrol
object being a hard dependency.(Error screen above, when control is missing)
Proposal
Provide a default value for the control prop internally, so avoid run time error when
control
object is missing not passed down.Props
Cons
control
object, consider it's really an internal used objectPR (draft)
#7046
cc @barrymay @kotarella1110 @jorisre @wdfinch @getTobiasNielsen
Beta Was this translation helpful? Give feedback.
All reactions