useRef vs createRef: why createRef breaks in function components | React Interview Deep Dive #13

Publié le: 08 juillet 2026
sur la chaîne: React Deep Dive
10
4

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


Sur cette page du site, vous pouvez voir la vidéo en ligne useRef vs createRef: why createRef breaks in function components | React Interview Deep Dive #13 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur React Deep Dive 08 juillet 2026, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 10 fois et il a aimé 4 téléspectateurs. Bon visionnage!