DEV Community

Discussion on: The Mysterious React hook: useRef()

Collapse
 
gsarig profile image
Giorgos Sarigiannidis

Nice! Coincidentally, I needed refs yesterday for the first time, on a WordPress Gutenberg plugin using react-leaflet. Leaflet doesn't allow accessing an existing map element by id, so I had to pass the object in a ref, which worked fine.

Collapse
 
exploreraadi profile image
Aadi

Wow! Great man and I've used leaflet.js too when I built my first ever web app using JavaScript. It was a location bookmark app.
Hope my article helped you clear things up🙌

Collapse
 
imkleats profile image
Ian Kleats

Had my useRef trial-by-fire back in June for the same reasons =D. It's handy for holding & interacting/controlling class instances that would otherwise persist across & perform their own DOM manipulations outside of the React component lifecycle.