Skip to content

Typescript error with useTextField and useRef #2556

Answered by bdow
DanBlakeNZ asked this question in Q&A
Discussion options

You must be logged in to vote

The useTextField is returning attributes for either an HTMLInputElement, or HTMLTextAreaElement. When you spread the props onto an <input />, you can cast it and that'd fix your TS errors:

<input {...(inputProps as React.InputHTMLAttributes<HTMLInputElement>)} ref={ref} />

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DanBlakeNZ
Comment options

Answer selected by DanBlakeNZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants