React Hooks changed the game when they came out! They are a simpler way to encapsulate stateful behavior and side effects in a user interface while...
For further actions, you may consider blocking this person and/or reporting abuse
I love how you explain things in such a clear way. Thanks!
Thanks David! :)
Great illustrations and awesome explanation. Thanks, Keep it up!
Thank you for reading and the words of encouragement Carlos!
Milu, I love this article
Thank you!!! :)
Great article on the underpinnings and usage of useRef. Your examples and illustrations do a great job of showing practical usage. However, your discussion about createRef is somewhat misleading. createRef "creates a new instance of the ref on every render instead of keeping a value between renders" is only true within a function component. createRef should not be used in function components. It should be used in class components where a new instance is not created on every render.
Thank you for pointing this out Greg! I haven't used class components since React hooks came out and I shouldn't have assumed everybody is on the same boat as me. I've updated my post to clarify the use of createRef. Thanks again for the feedback!
Illustrations, pictures, clear examples. Valuable content. Thanks so much for sharing that! It is my new favorite series about Hooks.
Thank you Diego! I really appreciate your feedback :)
This was awesome! I'll pass it along to some learners I know! Great work!!
Thank you for the kind words and for sharing this post Jacob!
Yeah!!! Besides being great info on React, this is the level of quality we should all be striving for in our technical articles! 🔥
Thank you Felix! This comment encourages me to continue sharing content :)
Thanks for this article and the codepen examples!
One question, in your "Where should you update a useRef() value?" example, you have
testRef = testRef.current + 1
. Can it just betestRef.current + 1
? I believetestRef
is a plain object, so there's no need to settestRef
equal to a number; it's enough to update thecurrent
property.Great work! Crystal clear explanation!
Thank you! :)
I always struggled with hooks other than useState and useEffect. Thank you for explaining it elegantly
Thank you Usman! :)
Best article that i could find on useRef. Great work Milu.
Thank you so much, great explanation!
Great post, learnt a lot.
Thanks Milu.
Thanks Vipin!
5 star content.