Skip to main content
React Interview Questions Theory P0 Medium

useRef vs useState

Choose between state and a ref for an on-screen counter, a timer ID and a DOM node.

Official Reference

Model Answer & Explanation

State is for values that affect rendering. A ref object persists across renders and setting current does not request a render. Use a ref for an imperative value such as a timer ID or DOM node. Don’t use ref mutations as a hidden rendering input.

Follow-up Interview Question · How would you clear a timer on unmount without making the timer ID state?

Module Context & References

React · Rendering & hooks theory Explain renders, reconciliation, keys, state, effects and performance
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.