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 have a base component which by surprise, contains checkbox + (input text field or input file field). checkbox determines which one(text field or file field) to appear.
Currently, in this base component, I use useFormContext and in the parent, I do FormProvider. This helps me that this base component also has a validation....
I use this base component in multiple places and some other package(not mine) needs to use it in the future. The problem is that because some other package might need to use this base component, writing useFormContext and <Controller> and many things from react-hook-form in the base component seems wrong to me, because this way, it's not a base component anymore, and is coupled to specific validation package - in this case - react-hook-form.
The purpose: What I want is to still have this base component without coupling anything to react-hook-form from this base component and still, I want this component to have validations for input type file and input text field..
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.
-
Hi @bluebill1049
I have a base component which by surprise, contains checkbox + (input text field or input file field).
checkbox
determines which one(text field or file field) to appear.Currently, in this base component, I use
useFormContext
and in the parent, I doFormProvider
. This helps me that this base component also has a validation....I use this base component in multiple places and some other package(not mine) needs to use it in the future. The problem is that because some other package might need to use this base component, writing
useFormContext
and<Controller>
and many things from react-hook-form in the base component seems wrong to me, because this way, it's not a base component anymore, and is coupled to specific validation package - in this case - react-hook-form.The purpose: What I want is to still have this base component without coupling anything to react-hook-form from this base component and still, I want this component to have validations for
input type file
andinput text field
..Is there some good practice doing what I want ?
Thank you in advance..
Beta Was this translation helpful? Give feedback.
All reactions