0
What’s the difference between useRef and createRef, and why is one better in function components?
subina kallyani
medium
3completed
152
Answer
createRefcreates a new ref every render → in function components it resets on each render, losing stored values.useRefreturns the same ref object across renders, making it stable.
So in function components, always preferuseReffor persistent references.
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0