Skip to main content
React Code Completion Hard +35 XP

useRef Access

Complete to access the DOM input element.

ReactFill in the blank
const inputRef = useRef(null);
<input ref={inputRef} />
// focus the input:
inputRef.___focus();

Type the missing code

Show answer and explanation

Answer: current.

useRef returns an object with a .current property that holds the DOM node. Access it via ref.current.focus().

Hint: The DOM node lives on which property of the ref?

What this challenge tests

Code Completion in React: useRef, dom.

Related challenges