Replies: 1 comment
-
I am also exploring ways to make this happen. I would like to associate some data to the ref so that during my final error processing (handleSubmit ( ... , errorHandlerFn ) , I can extract some custom data related to the field. |
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.
-
When I
register
, I want to add some custom data to the ref, is this safe and possible?I was thinking of doing this with
useController
, I am on React Native:My goal is, on validate, to get the label of the field and show it in a modal like:
Hack that works, but I'm not sure if safe
I came up with this hack, it abuses
setCustomValidity
as that is one thing gets exposed byuseController
, but is it safe?I saw
setCustomValidity
is exposed here - but I don't think it's used for anything so I abuse it -react-hook-form/src/useController.ts
Line 133 in 09d51cf
So now I can do:
And
labelOfAmount
is the correct label.Beta Was this translation helpful? Give feedback.
All reactions