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/useEffect

Synchronizing a component with something outside React after it renders.

10 QuestionsAdvancedHigh Priority ~12 min read

useEffect runs after the browser has painted, and it exists specifically for synchronizing a component with something outside React's own rendering — subscriptions, direct DOM manipulation, network requests, timers. It's not meant for computing a value derived from existing props or state, which should usually just be calculated directly during render instead of stored in an effect-updated state variable.

The dependency array controls when the effect re-runs: omit it entirely and the effect runs after every render, pass an empty array and it runs once after mount, pass specific values and it re-runs whenever any of them change. The cleanup function (the function an effect can return) runs before the next effect execution and on unmount — and forgetting it, or omitting a dependency the effect actually uses, is the single most common source of stale closures and subtle bugs in effect-heavy code.

What you'll walk away knowing

What useEffect is actually for — synchronizing with something outside React, not computing derived state
How the dependency array determines when an effect re-runs, and what an empty array really means
What the cleanup function does, and exactly when it runs relative to the next effect and unmount
Why omitting a dependency causes a stale closure bug, and why the linter warning shouldn't be silenced casually
1Explain all dependency array scenarios in the useEffect hookIntermediate2What are reactive values and what to be careful about with dependencies of useEffect?Intermediate3Explain how useEffect can be used to replicate the functionality of component lifecycle methods.Intermediate4When we should avoid useEffect?Intermediate5What is an external system with which useEffect allows syncronisation?Intermediate6Why fetching data inside effect is not prescribed?Intermediate7Discuss useEffect hookIntermediate8Discuss how setup and cleanup function is called in useEffect hook?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.