useRef
useRef is a React Hook that returns a persistent mutable object whose current property can hold a value across renders without causing re-rendering when changed.
React Hooks in Action: With Suspense and Concurrent Mode
useRef is a React Hook that returns a persistent mutable reference object whose current value can hold a DOM element or other value without causing re-rendering when changed.
- How it is used
- Manages persistent, mutable values and DOM references when changing them should not trigger immediate UI re-rendering.
- How deep it goes
- Explains the current property, render persistence, state comparison, timers, DOM access, focus, and uncontrolled inputs.
- Examples
- Uses counters, timer IDs, Presentation Mode, button focus, and an uncontrolled WeekPicker text box.
- What you can do after
- Apply it to persist mutable values, cancel timers, focus elements, and read uncontrolled DOM inputs.
Read how React Hooks in Action: With Suspense and Concurrent Mode explains useRef →
D3.js in Action, Third Edition
useRef() is a React hook that creates a persistent mutable reference object across component renders.
- How it is used
- Connects React-rendered elements to D3 code that controls selected portions of a visualization.
- How deep it goes
- Explains initialization, attachment, current-element selection, and effect placement, but defers broader ref behavior.
- Examples
- Uses a D3-controlled scatterplot group and a hybrid curve component that transitions an SVG path.
- What you can do after
- Build it from scratch by wiring a React ref to an SVG element and using D3 on its current instance.
React Quickly, Second Edition
useRef is a React Hook that returns a mutable reference object whose value persists across renders without causing a re-render when changed.
- How it is used
- Stores component values that should not trigger rendering and provides references to DOM elements used in UI behavior.
- How deep it goes
- Works through `current` updates, DOM attachment, and effect-driven element access using small components.
- Examples
- Demonstrates a double-click counter, an autofocus input, and an outside-click menu.
- What you can do after
- Apply it via React to retain non-render data or access DOM nodes for focus and event handling.
Also covered in
- Acing the Frontend InterviewIn early access (MEAP)
- React in Depth
What to know first
- renderingRendering is the process of producing a presentational representation or visual output from structured content, data, application state, or a scene.
- timerA timer is a mechanism that tracks or schedules time to trigger an event or action after a specified duration or at recurring intervals.
Related concepts
- refproduces · A ref is a mechanism for retaining access to a rendered element, component, or value outside ordinary rendering data flow.
- Reactuses · React is an open-source JavaScript library for building user interfaces from declarative, reusable components.
- React hookkind of · A React Hook is a function-based API that enables function components to access state, effects, context, and other React capabilities.
- current propertyuses · A ref’s current property is a mutable property that stores the value currently referenced or retained by the ref.
- callbackkind of · A callback is a function or other callable supplied or registered with a component for invocation at a specified event, condition, or point in execution.
- dom referenceuses · A DOM reference is a program-held reference to an actual DOM element rendered in a document.
Questions about useRef
What is useRef?
useRef is a React Hook that returns a persistent mutable object whose current property can hold a value across renders without causing re-rendering when changed.
Which Manning books explain useRef?
React Hooks in Action: With Suspense and Concurrent Mode, D3.js in Action, Third Edition and React Quickly, Second Edition.
What should I know before learning useRef?
Manning books that teach useRef usually introduce rendering and timer first.
What is useRef a kind of?
useRef is a kind of React hook. A React Hook is a function-based API that enables function components to access state, effects, context, and other React capabilities.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


