useRef

Pascual Vila
Frontend Instructor.
useRef is a hook that allows you to create a mutable reference that persists across renders. It is useful for accessing a DOM element or storing values that do not cause a re-render when they change.
Example of useRef:
{`import React, { useState, useRef } from "react";
function FocusInput() {
const inputRef = useRef(null);
const handleClick = () => {
inputRef.current.focus();
};
return (
<div>
<input ref={inputRef} type="text" />
<button onClick={handleClick}>Focus Input</button>
</div>
);
}
export default FocusInput;`}