Question · JavaScript and React course · Module 12: React and TypeScript
Typing useRef for a DOM Element
How do you correctly type useRef to store a reference to an input element?
Answer options
- useRef(document.getElementById('input'))
- useRef<HTMLInputElement>(null)
- useRef<Input>(null)
- useRef<DOMInput>(null)
You can check the correct answer by solving this task in the CodeWorlds game.