Never Forget React forwardRef Again

  Рет қаралды 15,375

Coding in Public

Coding in Public

8 ай бұрын

forwardRef can be confusing when moving from vanilla JavaScript. Once you think like React, however, it both makes sense and is more useful than you'd think.
🔗 Key Links 🔗
- Code: github.com/coding-in-public/r...
- Forward Ref docs: react.dev/reference/react/for...
---------------------------------------
🌐 Connect With Me 🌐
- Website: codinginpublic.dev
- Blog: chrispennington.blog
- Twitter: / cpenned
- Patreon: / coding_in_public
- Buy Me a Coffee: www.buymeacoffee.com/chrispen...

Пікірлер: 67
@alinikpey5797
@alinikpey5797 7 ай бұрын
Watching 10 video to understand what is userRef and forwardRef and why it is called ref untill i heard the answer from you. Thank you. that was a nice explanation
@CodinginPublic
@CodinginPublic 7 ай бұрын
That’s so kind! Glad it was such a help! Thanks!
@SouravDuttaROCKSTAR
@SouravDuttaROCKSTAR 8 ай бұрын
One of the best explanation for forwardRef. Short yet precise.💯
@CodinginPublic
@CodinginPublic 8 ай бұрын
Glad it was a help! Thanks for saying something!
@raldskie23
@raldskie23 8 ай бұрын
This is the clearest explanation of forwardRef ive ever watched and learned. Just straight up to the point, with proper context to the premise. 🔥
@CodinginPublic
@CodinginPublic 8 ай бұрын
So glad it was a help! I find that my clearest videos are the ones that come out of errors I make because it forces me to get to the bottom of why things are the way they are. Glad it was a help to you, too!
@akash-kumar737
@akash-kumar737 8 ай бұрын
Very well explained I always wondered how forwardRef work. Cheers 🍻 mate.
@CodinginPublic
@CodinginPublic 8 ай бұрын
Glad it was a help!
@grant_vine
@grant_vine 8 ай бұрын
Nice overview and so simply shown
@CodinginPublic
@CodinginPublic 8 ай бұрын
So glad it was a help!
@morchellemusic2829
@morchellemusic2829 7 ай бұрын
Thanks for the explanation, very clear and concise
@CodinginPublic
@CodinginPublic 7 ай бұрын
Glad it was helpful!
@__greg__
@__greg__ 5 ай бұрын
This was a great explanation, thanks for sharing!
@CodinginPublic
@CodinginPublic 5 ай бұрын
Glad it was a help!
@osifojohn1513
@osifojohn1513 Ай бұрын
Love this video, you cleared all my doubts.
@CodinginPublic
@CodinginPublic Ай бұрын
Glad it was helpful!
@DashFactsCentral
@DashFactsCentral 4 ай бұрын
Very beautifully explained! Thanks alot!
@CodinginPublic
@CodinginPublic 4 ай бұрын
Glad it was helpful!
@chihuhahuana4863
@chihuhahuana4863 Ай бұрын
this video was actually so cool. thanks man!
@CodinginPublic
@CodinginPublic Ай бұрын
Glad you liked it!
@ahtshamsaleem2970
@ahtshamsaleem2970 2 ай бұрын
keep making more videos like these i loved it
@sahilrathod3930
@sahilrathod3930 7 ай бұрын
Great explanation... ❤
@CodinginPublic
@CodinginPublic 7 ай бұрын
Thanks for saying something! Glad it was a help!
@yutsacarm8021
@yutsacarm8021 Ай бұрын
Omg !!!!! This is the. Best explanation of useRef video !!!
@CodinginPublic
@CodinginPublic Ай бұрын
Glad it was helpful!
@RandomMcLain
@RandomMcLain 8 ай бұрын
🎯 Key Takeaways for quick navigation: 00:34 🤖 React relies on createElement to generate elements in the virtual DOM. 02:26 🛡️ useRef helps bridge the gap between the virtual DOM and the actual DOM for direct access. 03:22 💼 Understanding when to use forwardRef: when a component needs access to the actual DOM node, not just the virtual DOM. 05:14 🛡️ How to implement forwardRef in JavaScript and TypeScript, passing the ref down to child components. 08:30 🤖 Utilizing the children prop for dynamic content within a component. Made with HARPA AI
@CodinginPublic
@CodinginPublic 8 ай бұрын
Thanks, my friend!
@godofwar8262
@godofwar8262 8 ай бұрын
Thank you finally a react video
@CodinginPublic
@CodinginPublic 8 ай бұрын
Ha :) hopefully more to come!
@prashlovessamosa
@prashlovessamosa 8 ай бұрын
Thanks for sharing please make more react stuff.
@CodinginPublic
@CodinginPublic 8 ай бұрын
Glad you enjoyed it!
@minyoungna6642
@minyoungna6642 8 ай бұрын
Agreed!!
@K.Huynh.
@K.Huynh. 8 ай бұрын
thank for sharing! So cool 😎
@CodinginPublic
@CodinginPublic 8 ай бұрын
Glad it was a help!
@Firewallx2
@Firewallx2 2 ай бұрын
Thanks!
@CodinginPublic
@CodinginPublic 2 ай бұрын
You’re welcome!
@mounis
@mounis 8 ай бұрын
Sorry for the out of context question, which font do you use? And BTW amazing explanation.
@CodinginPublic
@CodinginPublic 8 ай бұрын
No worries. Cascadia code. Free font by Microsoft.
@Aaronmoreno
@Aaronmoreno 5 ай бұрын
So clear! I’m won over. I subbed
@CodinginPublic
@CodinginPublic 5 ай бұрын
Great! Glad it was a help!
@adarsh-chakraborty
@adarsh-chakraborty 8 ай бұрын
Thanks
@CodinginPublic
@CodinginPublic 8 ай бұрын
Glad it was a help.
@ahmadm.hawwash3931
@ahmadm.hawwash3931 14 күн бұрын
Great video, thanks for sharing! Can't we pass it as another prop name? I mean we could pass as reference instead of ref. Could that solve the issue?
@VishalSharma-rn7mt
@VishalSharma-rn7mt 6 ай бұрын
Awesome
@ronaldpaek
@ronaldpaek 8 ай бұрын
I have a question about IDE's I remember watching some of your older videos and you used to use Nova IDE, just wanted to hear why you switched back to VS code I haven't seen many people use Nova IDE so I would love to hear about the Pros / Cons of Nova vs VS Code.
@CodinginPublic
@CodinginPublic 8 ай бұрын
I haven’t used nova in a while, so I’m sure they’re much better now. I loved it but between viewers on the channel wanting to see VSCode and the lack of support for things like Astro originally, I switched.
@ronaldpaek
@ronaldpaek 8 ай бұрын
that makes sense, I feel like most viewers/supporters will be using vs code 😆@@CodinginPublic
@mohammadalrefaai4377
@mohammadalrefaai4377 6 ай бұрын
Actually the form could have one responsibility it could have the form and their inputs also the behavior of the inputs, it's cleaner 😊
@CodinginPublic
@CodinginPublic 5 ай бұрын
Could you explain more what you mean here?
@user-lt1jr2gh4t
@user-lt1jr2gh4t 7 ай бұрын
can we forward multiple refs at once to a component?
@CodinginPublic
@CodinginPublic 7 ай бұрын
No, and something I should have mentioned (at least I don’t think you can). Typically you componetize individual inputs or items that need a ref (so single elements) when forwarding refs.
@Kraszer
@Kraszer Күн бұрын
Just pass refs as normal props. It works on older React versions too like 17.0.0. I don't understand why to even use fowardRef.
@nicus1504
@nicus1504 15 күн бұрын
You CAN pass refs directly as props
@CodinginPublic
@CodinginPublic 15 күн бұрын
You can now in react 19. :)
@Kraszer
@Kraszer Күн бұрын
@@CodinginPublic Not true, you could pass refs as props before, and it just worked. I tested in on React 17.0.0. I spend some time on internet and still really didn't understand why fowardRef exists.
@ayushnautiyal9469
@ayushnautiyal9469 5 ай бұрын
What about multiple refs. If we want to pass multiple refs than how we use forwardrefs.
@CodinginPublic
@CodinginPublic 4 ай бұрын
You don't :) The idea is to have each component as it's own standalone. So you'd have a single input with a forwardRed that you would embed in a form that might have another forwardRef, etc.
@Kraszer
@Kraszer Күн бұрын
Just pass refs as normal props. It works on older React versions too like 17.0.0. I don't understand why to even use fowardRef.
@Pareshbpatel
@Pareshbpatel 3 ай бұрын
{2024-03-22}
@CodinginPublic
@CodinginPublic 3 ай бұрын
Paresh was here. 👋
@anhdunghisinh
@anhdunghisinh 3 ай бұрын
And now they ditch forwardRef :v
@CodinginPublic
@CodinginPublic 3 ай бұрын
lol i know, right?
@ChristinaCodes
@ChristinaCodes 8 ай бұрын
This is by far the best forwardRef video I’ve ever seen, it finally makes sense 🥲 Thank you so much for this.
@CodinginPublic
@CodinginPublic 8 ай бұрын
You’re welcome! Glad it was such a help! That’s so…
@carlandres3319
@carlandres3319 4 ай бұрын
Thanks
@CodinginPublic
@CodinginPublic 4 ай бұрын
You’re welcome!
Learn React Hooks: useLayoutEffect - Simply Explained!
9:17
Cosden Solutions
Рет қаралды 16 М.
Goodbye, forwardRef
15:59
UI Engineering
Рет қаралды 6 М.
Red❤️+Green💚=
00:38
ISSEI / いっせい
Рет қаралды 60 МЛН
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 57 МЛН
ОСКАР vs БАДАБУМЧИК БОЙ!  УВЕЗЛИ на СКОРОЙ!
13:45
Бадабумчик
Рет қаралды 5 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 1,3 МЛН
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 470 М.
React Hook useRef and forwarding refs with forwardRef
14:46
techsith
Рет қаралды 80 М.
Authoring Components with CVA + tailwindcss - Basic Buttons (1 / 4)
17:04
React Tips with Brooks Lybrand
Рет қаралды 2,4 М.
7 React Lessons I Wish I Knew Earlier
7:30
Code Bootcamp
Рет қаралды 57 М.
Why I Chose Rust Over Zig
33:18
ThePrimeTime
Рет қаралды 13 М.
React Dialogs (the right way)
15:46
Coding in Public
Рет қаралды 6 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 196 М.
Самые загадочные хуки - useImperativeHandle и forwardRef
9:42
Веб-разработка - DevMagazine
Рет қаралды 8 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 462 М.
A Trick Every React Developer Should Know: Ref Forwarding
9:08
Josh tried coding
Рет қаралды 18 М.
原来小蚂蚁会魔法?#火影忍者 #佐助 #家庭
0:17
火影忍者一家
Рет қаралды 1,1 МЛН
УТОПИЛА ДОРОГУЩИЙ ТЕЛЕФОН 😭
1:01
Аня Панкова
Рет қаралды 10 МЛН
Sweet watermelon 🍉😋
0:15
LizAlex Fam
Рет қаралды 10 МЛН
Loop? ❤️ #behindthescenes ?
0:11
The Quinetto's
Рет қаралды 3,8 МЛН
Всегда проверяйте зеркала
0:21
Up Your Brains
Рет қаралды 10 МЛН