liveBook · Manning

Ref

Also called reference

A ref is a mechanism for retaining access to a rendered element, component, or value outside ordinary rendering data flow.

How 4 Manning books explain it

React Hooks in Action: With Suspense and Concurrent Mode

A React ref is a persistent mutable object that provides access to a value, commonly a rendered DOM element, through its current property.

How it is used
Uses refs for non-rendering values, timer identifiers, DOM elements, focus management, and uncontrolled form fields.
How deep it goes
Explains useRef, current, render persistence, timers, focus, and uncontrolled inputs, while recommending controlled components for form state.
Examples
Demonstrates counters, timer-driven Presentation Mode, automatic button focus, and date entry through an uncontrolled text box.
What you can do after
Apply it via useRef to persist mutable values, cancel timers, focus DOM elements, and read uncontrolled inputs.

Read how React Hooks in Action: With Suspense and Concurrent Mode explains ref →

D3.js in Action, Third Edition

A React ref is an object or callback mechanism that provides access to a rendered component or DOM element.

How it is used
Connects a React-rendered element to D3 when D3 needs to control part of the DOM.
How deep it goes
Walks through ref initialization, attachment, and D3 selection in an effect, including dependencies for an animated path.
Examples
Uses a D3-controlled scatterplot group and a transitioning curve path.
What you can do after
Apply React refs to let D3 select and manipulate a rendered element inside an effect.

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

Web Component Development with Modern Libraries and Tooling

A template directive function or attribute that captures a reference to a rendered DOM node in a property.

How it is used
Connects rendered custom elements to component logic for initial property updates and event-driven changes.
How deep it goes
Shows reference declarations and post-render access in component examples, but only briefly mentions wrec’s ref attribute.
Examples
Pairs a greeting custom element with a radio-group whose selected color updates the greeting.
What you can do after
Apply it via React, Solid, or Vue to access rendered custom elements and update their properties.

Read how Web Component Development with Modern Libraries and Tooling explains ref →

React in Depth

A React ref is a special property that provides access to a rendered DOM node or component instance rather than being handled as an ordinary component prop.

How it is used
Exposes an internal rendered element to an outside component for imperative operations such as focusing an input.
How deep it goes
Explains forwarding, DOM assignment, TypeScript errors, and two typing strategies, then notes the React 19 simplification.
Examples
Uses a login form whose parent focuses a forwarded username input after rendering.
What you can do after
Build it from scratch by typing, forwarding, and attaching a ref to a custom input component.

Read how React in Depth explains ref →

What to know first

Related concepts

Questions about ref

What is ref?

A ref is a mechanism for retaining access to a rendered element, component, or value outside ordinary rendering data flow.

Which Manning books explain ref?

React Hooks in Action: With Suspense and Concurrent Mode, D3.js in Action, Third Edition, Web Component Development with Modern Libraries and Tooling and React in Depth.

What should I know before learning ref?

Manning books that teach ref usually introduce attribute, handler, JSX and natural language interface first.

What is the difference between ref and rendering?

A ref is a mechanism for retaining access to a rendered element, component, or value outside ordinary rendering data flow. Rendering is the process of producing a presentational representation or visual output from structured content, data, application state, or a scene.

What are the parts of ref?

Ref includes attribute.

What is ref also called?

Ref is also called reference.

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.