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
Hello everyone !
I have a small question about retrieving refs from ReactHookForm !
I currently have a set of Form components (Input, Select, CheckboxGroup, ...).
They are all using the useController hook with properly set props.
For one of my features, I need to be able to manipulate the refs of these components and I was looking for a way to abstract this logic so that it has no impact when writting the jsx part of the form.
Currently, I plan on managing my own little refs store that will be passed to my Components through a HOC.
Is there an easier way to do this ? Or a way to access the refs of all registered fields from react hook form's hooks ?
Currently I can only retrieve refs using control._fields._f.ref but I can't use some needed methods like scrollIntoView.
If anyone has ideas on how to do this more easily, not necessarily through RHF's APIs, I am also open to suggestions.
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.
-
Hello everyone !
I have a small question about retrieving refs from ReactHookForm !
I currently have a set of Form components (Input, Select, CheckboxGroup, ...).
They are all using the
useController
hook with properly set props.For one of my features, I need to be able to manipulate the refs of these components and I was looking for a way to abstract this logic so that it has no impact when writting the
jsx
part of the form.Currently, I plan on managing my own little refs store that will be passed to my Components through a HOC.
Is there an easier way to do this ? Or a way to access the refs of all registered fields from react hook form's hooks ?
Currently I can only retrieve refs using
control._fields._f.ref
but I can't use some needed methods like scrollIntoView.If anyone has ideas on how to do this more easily, not necessarily through RHF's APIs, I am also open to suggestions.
Thank you very much !
Beta Was this translation helpful? Give feedback.
All reactions