DEV Community

Discussion on: What is useRef hook and how do you use it?

sukhboldaltangerel profile image
Sukhbold Altangerel

What's the difference between useRef() and useRef(null)? I prefer, and could go with the undefined all the time, but online examples always go with the null. So I am wondering.

nibble profile image
Joseph Mawa Author

It is up to you to decide which one of the two to go with. The reason why people go with null over undefined boils down to the difference between the two. You can read about it here.