Custom Input: Best way to pass register and error #1864
-
Hey there! Very nice lib. I have a custom input component which also receives the error message. Here is how it is the calling tag currently:
Is there a default way to write something like
that would shorten it up? I will for now create a object that have both and only pass this object, but I want to know if there is a default way to do it, and if not, I strongly suggests that there should be! Something like regAndError on the useForm resulting object. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
you will have to |
Beta Was this translation helpful? Give feedback.
-
Awesome! Just what I needed! Tried and works like a charm. |
Beta Was this translation helpful? Give feedback.
<Input name="name" icon={FiUser} placeholder="Nome" aaa={bbb} />
you will have to
useFormContext
and register the input inside your component.https://react-hook-form.com/api#useFormContext