liveBook · Manning

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.

How 3 Manning books explain it

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.

Read how D3.js in Action, Third Edition explains useRef →

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.

Read how React Quickly, Second Edition explains useRef →

Related concepts

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.