DEV Community

Discussion on: React Hooks (useContext, useEffect, useState, useRef) Summarized Like Crazy (Short & Concise Article)

mrtnbroder profile image
Martin Broder • Edited

I'm sorry but that's bollocks. useRef has nothing to do with the DOM. It's stated clearly on the offical docs:

useRef returns a mutable ref object whose .current property is initialized to the passed argument (initialValue). The returned object will persist for the full lifetime of the component.
Enter fullscreen mode Exit fullscreen mode

Please don't spread false information.

useRef is useful whenever you want to reference the same value on every render, but not trigger a re-render when its value changes.

Thread Thread
hcbartelt profile image
Hans Christian Bartelt

That's it. Thank you 👍

Thread Thread
ishakmohmed profile image
Mohmed Ishak Author • Edited

@mrtnbroder apparently you're right, my bad. I just need to remove the "DOM" part in that comment, will edit it now. That's how I always understood the useRef hook. Thanks dude.