missing values on result of register function #12349
Unanswered
SJongbloets
asked this question in
Q&A
Replies: 1 comment
-
In the same boat. With this:
I get this in the DOM: <input id=":R4opuuunl7:-form-item" aria-describedby=":R4opuuunl7:-form-item-description" aria-invalid="false" name="name"> Would expect |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I'm have a question regarding the output of the register function.
When i look at the code, it says it's return value is of type
UseFormRegisterReturn
but when i look at the ouput i'm missing the optional values on it. (highly likely that i'm missing something in how i currently use it)The use-case for me is the following:
We have a wrapper component, that holds the actual
<input />
element that we pass theregister
function to.This wrapper component, provides us with some styling for a label, the input field and a possible error message, but we'd like to also add an extra class based on if the field is required.
The way we solve this now, is to pass an extra prop to the wrapper component, but I saw that the
register
return function actually has an optional required value.The problem i'm currently having, is that no matter what I do, i can't seem to get that required value to be returned by the register function. Is there anyway to get this value back? This would mean that we'd need to pass less properties to the wrapper component that it could already know.
Version
7.53.0
CSB link:
https://codesandbox.io/p/sandbox/react-hook-form-register-return-rs5x9t
I hope i've described my issue clearly, any help would be appreciated.
Kind regards,
Beta Was this translation helpful? Give feedback.
All reactions