[HELP] Input DomRef Register Property 'current' is missing
See original GitHub issueHello, I am using React Bulma Components and React Form Hooks packages. At the input:
type FormValues = {
email: string;
password: string
}
const {
register,
handleSubmit,
formState:
{
errors,
isSubmitSuccessful,
isSubmitting
}
} = useForm<FormValues>();
#return
<Form.Input
name="email"
domRef={register({required: true})}
type="email"
placeholder="e.g. bobsmith@gmail.com"
required
/>
Gives me this error:
Property ‘current’ is missing in type ‘UseFormRegisterReturn’ but required in type ‘RefObject<“input”>’.
Its inside a functional component. I think I am doing something completely wrong and misunderstanding something,
I found same issue here but I couldn’t understand how to fix this.
I tried this fix: #343 (comments)
But then I get this error because I use functional component?
Thanks a lot.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to use refs in React with Typescript - Stack Overflow
When the component mounts, the ref attribute's current property will be assigned to the referenced component/DOM element and assigned back to ...
Read more >Refs and the DOM - React
createRef() receives the underlying DOM element as its current property. When the ref attribute is used on a custom class component, the ref...
Read more >React Refs with TypeScript - Medium
React will assign the current property with the DOM element when the component mounts, and assign it back to null when it unmounts....
Read more >Understanding refs in Vue - LogRocket Blog
Refs are Vue.js instance properties used to register a reference ... Vue's ref helps you “reference” DOM elements in a more efficient way....
Read more >Template Refs - Vue.js
To achieve this, we can use the special ref attribute: template <input ref="input">. ref is a special attribute, similar to the key attribute...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm that this works, thank you @sebzieja 🤝
That piece of code works in TS. It is not so elegant as it only works for Form.Input, but works