React refs keep telling me ref.current.value does not exist on type 'never'

I've sent a few pics of where the error is. The function is responsible for checking whether a field among a set of required input fields is filled in or not. If one of them is not filled it will stop the function.
No description
No description
11 Replies
Neto
Neto•16mo ago
what is the type of refs?
🇵🇸 Prince Toast
All refs are set to null since they are used with components/elements
Neto
Neto•16mo ago
you probably need to type the refs ts isnt inferring them, and its slapping a never
🇵🇸 Prince Toast
ah alright, so a type that extends the React.MutableRefObject<null> type?
Neto
Neto•16mo ago
what are the types of the refs? basically the useRef lines
🇵🇸 Prince Toast
sry for late reply here you go
No description
Neto
Neto•16mo ago
You probably need to type those useRefs
Neto
Neto•16mo ago
TypeScript: React useRef Hook
How to use React's useRef Hook with TypeScript for using a ref ...
Neto
Neto•16mo ago
Like this
🇵🇸 Prince Toast
That helped me solve the issue, thanks :)
Want results from more Discord servers?
Add your server