-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

React Interview Guide
By :

DOM manipulation is taken care of by the React library under the hood, without the need for any manual DOM updates. But sometimes, you might encounter use cases (focusing, scrolling to specific elements, and so on) to have DOM element access managed by React. As a solution to these use cases, refs have been introduced to access the DOM nodes.
A React interviewer might expect a good knowledge of DOM access and possible use cases, both of which cannot be handled through a traditional declarative approach.
Ref is the shorthand for a reference to an element or a component. Refs are used to access DOM nodes or React elements that are created in the render method. The reference to the DOM element is available in the current
attribute of the ref. In other words, refs are plain JavaScript objects with additional current property. To understand this ref concept in a better way, let’s look at an example...