DEV Community

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

Collapse
 
erchis profile image
erchis

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.

Collapse
 
nibble profile image
Joseph Mawa

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.