Oh, you definetly should mention other uses of useRef! It's really incomplete and useRef is for far more than just refferencing elements. From docs: 'However, useRef() is useful for more than the ref attribute. It’s handy for keeping any mutable value around similar to how you’d use instance fields in classes.'.
Just one example that I actually use more than refferencing elements... When you want to avoid running useEffect on mount of the component: stackoverflow.com/questions/594926...
Oh, you definetly should mention other uses of useRef! It's really incomplete and useRef is for far more than just refferencing elements. From docs: 'However, useRef() is useful for more than the ref attribute. It’s handy for keeping any mutable value around similar to how you’d use instance fields in classes.'.
Thanks for this comment. Very valuable info. I will definitely take a look at this and update this post with my learning!
Just one example that I actually use more than refferencing elements... When you want to avoid running useEffect on mount of the component: stackoverflow.com/questions/594926...
More examples here: dmitripavlutin.com/react-useref-gu...
Thanks for this! I'm sure this will come in handy for me.