nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

TOPIC OVERVIEW

react/Refs

An escape hatch to reach a DOM node or persist a value without triggering a re-render.

10 QuestionsIntermediateMedium Priority ~10 min read

useRef returns an object with a mutable .current property that persists across renders without causing a re-render when it changes. It serves two genuinely different purposes: attaching to a DOM element to interact with it imperatively (focusing an input, measuring an element, scrolling into view), and holding any value you want to survive across renders without it being part of what gets rendered — a timer ID, a previous value for comparison, a flag.

Because refs aren't passed down like normal props, a parent can't simply pass ref={someRef} to a custom component and expect it to reach that component's underlying DOM node — forwardRef exists specifically to let a component explicitly accept and forward a ref to whatever it wants. useImperativeHandle goes a step further, letting a component customize exactly what a parent-attached ref exposes, instead of handing over the raw DOM node.

What you'll walk away knowing

The two distinct uses of useRef: DOM access and persisting a mutable value across renders
Why updating a ref doesn't trigger a re-render, unlike updating state
Why forwardRef is needed to let a ref pass through to a child's underlying DOM node
What useImperativeHandle does, and why it's used sparingly
1When should we use the callback ref method for creating refs?Intermediate2How do you create and use refs?Intermediate3What things can be referenced using refs? Use cases of refs?Intermediate4What are refs and why do we need them?Intermediate
All Topics
1
Basics
JSX
State and Props
Components
Function Components
2
Virtual DOM
Reconciliation
Class Components
Lifecycle functions
3
Hooks
useState
useReducer
useMemo
useContext
useCallback
useEffect
Custom Hooks
New Hooks
4
Code Sharing
HOC
Refs
Data Sharing
Events
Context API
5
Redux
Router
CSR-SSR
React APIs
ReactDOM
Strict Mode
6
Performance Optimisation
Security
Sharethis topic

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.