How to pass an input ref to rac's TextField? #4792
-
What's the right way to pass an input ref to react-aria-component's TextField? Using this example, should I create a forwardRef for MyTextField and pass the ref to Input? I see that TextField also takes a ref, but it seems to go on the div.
In case someone was wondering what for: react-hook-form needs to pass a ref so it can call ref.focus() when an error exists on submit. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Yeah I think the right way is to pass a |
Beta Was this translation helpful? Give feedback.
-
@devongovett one more... do you happen to know the best place to put this for the Select component? |
Beta Was this translation helpful? Give feedback.
Yeah I think the right way is to pass a
ref
directly to theInput
element. You could do that usingforwardRef
, or by adding aninputRef
prop to your component for example.