ref
A React handle that points at a real DOM element, so code can focus it, measure it or attach listeners.
In more detail
Consumers often pass a ref to a design system component and expect it to reach the underlying element. When a component also needs its own ref to that element, a helper such as composeRefs combines both so each receives the node.
Example
<input ref={inputRef} />Related terms
- asChild — A prop that tells a component to render its single child element instead of its own, merging its classes, props and behaviour onto that child.
- React hook — A function whose name starts with use, such as useState or useEffect, that lets a React component keep state or run side work.
- DOM — The tree of objects a browser builds from a web page, which scripts read and change to update what is on screen.
- useRef — The React hook that creates a ref object, { current: initialValue }, which stays the same object for the life of the component.
- escape hatch — A feature that lets you step outside the normal React model, such as refs and Effects, for the cases React cannot express declaratively.
- useImperativeHandle — The React hook that lets a component choose exactly which methods its parent gets through a ref, instead of the raw DOM node.
Taught in
- Polymorphism & Slotted Composition: The asChild Pattern — Design Systems & Component Engineering
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering
- SyntheticEvent System: Event Delegation in Modern React — React 19 & Modern Component Architecture
- useRef Mechanics: DOM References And Mutable Persistent State — React 19 & Modern Component Architecture
- useImperativeHandle: Controlled Ref Forwarding Boundaries — React 19 & Modern Component Architecture
- Creating Event Listener Hooks with Clean Teardown Logic — React 19 & Modern Component Architecture