Swacblooms🦋

Making the Moves
Menu
  • Home
  • Motivation
  • Education
  • Programming
  • About
  • Contact
  • Privacy Policy
Home
Programming
React- Forwarding Refs
Programming

React- Forwarding Refs

Samson Amaugo September 5, 2019

Yo guys I’m back and banging today with using React’s forwarding Technique.

Since React paradigm is based on components and its encapsulations with other components, sometimes you might want to gain access to the node of a child element in a parent element.

In the example above you can see that a ref was created. But the problem with the code above is that you can’t reach the button element in the SmileyButton’s component. So to make this work we are going to make use of the forwardRef procedure.

You need ref forwarding to allow a component to pass refs to their parent-child. An example can be seen below.

If you run the code above you would notice that you have access to the ref of the button. And therefore you can control it from its ancestral parents.

React.forward Refs receives two arguments: props and ref

Please note that the ref’s argument of React forward won’t work on regular functions and class components.

You can read up more on refs to increase your knowledge span.

Thanks guys… You can comment below to contribute

Prev Article
Next Article

Related Articles

easyssh
Hola 🖐….. Sometimes you might find it hard to keep …

Easy SSH Via Local DNS

mysocials
So I created a DotNet CLI tool called MySocials 😜 …

MySocials DotNet CLI Tool

About The Author

Samson Amaugo

I am Samson Amaugo. I am a full-stack developer and I specialize in DotNet and the MERN stack.

2 Comments

  1. Osinachi Victor Chukwujama

    Is this stuff working

    January 17, 2020
    • Sammy

      Yep it works quite well bro

      January 20, 2020

Leave a Reply

Cancel reply

Search Site

Recent Posts

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#

Categories

  • EDUCATION
  • Motivation
  • Programming
  • Uncategorized

Get more stuff

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

we respect your privacy and take protecting it seriously

RSS Swacblooms

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#
  • Hot Chocolate Data Loader: A Quick Guide
  • Exploring Policy-Based Authorization in Minimal API with .NET 8
  • Using Cloud Firestore in Blazor WebAssembly
  • Serving A VueJs App from DotNet
  • Dynamic Subscriptions in Hot Chocolate 🔥🍫

Swacblooms🦋

Making the Moves
Copyright © 2025 Swacblooms🦋
Swacblooms - Making the Moves