useRef and createRef look almost identical — both return an object with a current property — but one of them silently breaks in function components. This is a favorite interview question because it checks whether you understand how renders actually work.
After this breakdown you'll know why useRef hands you the same ref object on every render, why createRef makes a brand new one each time the function runs, the subtle DOM/effect bugs that causes, and when each one is the right tool.
In this breakdown:
0:00 useRef vs createRef — why interviewers ask
0:15 useRef: a mutable container that persists across renders
0:35 createRef: a brand new ref object on every call
0:51 The key difference: same ref vs new ref each render
1:01 Why createRef breaks in function components (and the fix)
1:18 When to use each (function components vs class fields)
1:37 The interview-ready answer
1:49 Mental model: useRef is a small pocket inside the component
📘 Full breakdown — 70 Mid/Senior interview questions in "React Interview Deep Dive":
→ Amazon: https://www.amazon.com/dp/B0GX36S9KF
→ PDF (Gumroad): https://ivandeinichenko.gumroad.com/l...
▶ React Deep Dive playlist: • React Interview Deep Dive — How React Actu...
#react #reactinterview #frontend #useref #createref #reacthooks
In questa pagina del sito puoi guardare il video online useRef vs createRef: why createRef breaks in function components | React Interview Deep Dive #13 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato React Deep Dive 08 luglio 2026, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 10 volte e gli è piaciuto 4 spettatori. Buona visione!