Ref
A ref is a mechanism for retaining access to a rendered element, component, or value outside ordinary rendering data flow.
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.
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.
What to know first
- attributeAn attribute is a named property or piece of information associated with an entity, object, or structured data item.
- handlerA handler is a software routine or component invoked to process an event, request, message, or other input.
- JSXJSX is a JavaScript syntax extension for expressing user-interface elements with XML-like or HTML-like markup that is transformed into JavaScript.
- natural language interfaceA natural language interface enables interaction with a system through human-language text or speech.
Related concepts
- useRefproduced by · 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.
- attributehas part · An attribute is a named property or piece of information associated with an entity, object, or structured data item.
- renderingcontrasts with · Rendering is the process of producing a presentational representation or visual output from structured content, data, application state, or a scene.
- text boxuses · A text box is an interactive user-interface control for entering, displaying, or editing text.
- Document Object Modeluses · The Document Object Model is a platform-independent programming interface that represents a document as a structured tree of nodes and provides ways to access and modify its content and structure.
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.



