What is useRef used for?
Model answer
useRef returns an object { current } that stays the same across renders, and changing it does not cause a re-render. Common uses: getting a DOM element (inputRef.current.focus()), and storing values that should persist without triggering rendering, such as a timer id or the previous value.
Learn this topic
React Context API Explained: Share Data Without Passing Props in the course React.js Full Course: Beginner to Advanced.
Sign in to add your own answer.