DEV Community

SATHISHKUMAR R
SATHISHKUMAR R

Posted on Edited on

What is current in React? What is focus()?

Current in React:

current is a property of useRef. It stores the referenced value or DOM element.

Example:

const inputRef = useRef(null);

Here, inputRef.current gives access to the input element.

Focus in React:

focus() is a JavaScript method used to automatically place the cursor inside an input field.

Example:

inputRef.current.focus();

Top comments (0)