DEV Community

loading...

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

ishakmohmed profile image
Mohmed Ishak Author

You're right. Not to worry, usually you don't need it.

Thread Thread
moustachedsign profile image
Moustache Design

yes, the difference is querySelector is imperative, useRef declarative, also querySelector does a search for the string you pass to it, so you have to know that is unique and won't change.
useRef on the other hand, ties itself to that jsx element and nothing else.

Thread Thread
ishakmohmed profile image
Mohmed Ishak Author

Cool!