-
I want to customize the ref of the component. |
Beta Was this translation helpful? Give feedback.
Answered by
ryansolid
Jul 15, 2021
Replies: 1 comment 4 replies
-
Oh sure. We don't have a hook for it. All you need to do is call props.ref as a function. The only caveat is it may not exist, which could be hidden behind a hook of sorts I suppose but you can also just check that it exists. Converting the example from the linked docs I think it's just this? function FancyInput(props) {
const inputRef = (el) => {
props.ref?.({
focus() { el.focus(); }
})
}
return <input ref={inputRef} ... />;
} |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
ryansolid
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh sure. We don't have a hook for it. All you need to do is call props.ref as a function. The only caveat is it may not exist, which could be hidden behind a hook of sorts I suppose but you can also just check that it exists.
Converting the example from the linked docs I think it's just this?