React Refs are a useful feature that act as a means to reference a DOM element or a function component from within a parent component.
We can get more idea by looking below example. you can put this file in /src/components folder and put
In above code, We create an object of useRef and assign it to inputRef. now inputRef given to input element ref. and In useEffect we write code that focus on textbox. While running this code, It will show focused on textbox and one object in console panel.
another example is as per below code.
In above code, useRef used to create a generic container that can hold a muteable value similars to instance property on a class component. when we click on button it will clear interval and increment of count is stopped.