Felix’s Newsletter

Share this post
How to use React's forwardRef function
felixgerschau.substack.com

How to use React's forwardRef function

Unterstanding ref forwarding

Felix
Sep 7, 2021
2
Share this post
How to use React's forwardRef function
felixgerschau.substack.com

Hey!

This article is about an issue I ran into recently.

A while ago, I wrote an article on React’s references and the useRef hook. When I had to use refs myself again, I wondered why the references to my custom React button component didn’t work.

The issue here was that just like the “key” prop, “ref” is a special property that doesn’t behave like others as it’s no part of the props that we access in our components.

Using the forwardRef function allows us to access the ref property and attach it to the HTML element of our choice.

I have explained the whole topic more in detail in the article. I hope you like it.

Read the article

Thanks for reading, and have a great week!

Felix


If you want to learn web development through online courses, you can currently get a 1-month premium membership of SkillShare with this link for free (cancel any time).

I also have a course published there in case you want to learn more about Progressive Web Apps 😉

Comment
Share
Share this post
How to use React's forwardRef function
felixgerschau.substack.com

Create your profile

0 subscriptions will be displayed on your profile (edit)

Skip for now

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.

TopNewCommunity

No posts

Ready for more?

© 2022 Felix Gerschau
Privacy ∙ Terms ∙ Collection notice
Publish on Substack Get the app
Substack is the home for great writing