React Hook useRef and forwarding refs with forwardRef

  Рет қаралды 81,407

techsith

techsith

Күн бұрын

useRef Hook and forwardRef to pass reference to a reactjs Component. To access html element and focus() Forwarding refs to DOM components
#react #useRef #forwardRef
Help the channel via patron and buying merchandise
/ techsith
teespring.com/...
Follow me for technology updates
/ techsith
/ techsith
/ techsith1
/ 13677140
/ patelhemil
Help me translate this video.
www.youtube.com...
Note: use translate.goog... to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.

Пікірлер: 120
@arpielen
@arpielen 4 жыл бұрын
You just made me a heroine on my internship program 🤩 Yeaeaaah, thank you!
@akashpal9691
@akashpal9691 3 жыл бұрын
A quick and precise intro to why forward ref is needed.
@stephenfairris4246
@stephenfairris4246 4 жыл бұрын
Was looking for a quick review of refs in React using hooks, and this video was exactly that. Well done :)
@janwillem4495
@janwillem4495 4 жыл бұрын
Same here! This video is a really good way to learn about the refs :)
@cpmcmanaman
@cpmcmanaman 3 жыл бұрын
Wow Techsith is good. Wish I had stumbled in him first in learning React Hooks....a lot of hours spent watching people try poorly rehash the examples/explanations on the Reactjs homepage. Love Techsith!!
@gabrielfono844
@gabrielfono844 3 жыл бұрын
this is one of the best developers I have ever accounted in my career. I learn class and functional component for free here. I learn about javascript advance concept like closure , oop and etc. I prepared for my mid-level React position thanks techsit. God bless you.
@clbmribas
@clbmribas 4 жыл бұрын
Nice tutorial, direct to the point and well explained. A relief after hours of frustrated research. Thank you.
@robbieyy
@robbieyy 4 жыл бұрын
I am so happy ... I just arrived at the point I found out you can't give ref's to function components.... but now I can. :-) Thanks
@KyleKatarn145
@KyleKatarn145 2 жыл бұрын
Awesome. I've just been passing the ref down as a prop because I didn't know any better, but I'm thinking this would work so much better. Thank you!
@ShubhamMishra-mz4zw
@ShubhamMishra-mz4zw Жыл бұрын
Thank you so much. This is probably the best explanation on useRef and forwardRef
@mahendranath2504
@mahendranath2504 3 жыл бұрын
Thank you for clarifying 👍🏼
@Techsithtube
@Techsithtube 3 жыл бұрын
Happy to help!
@radbrad5580
@radbrad5580 Жыл бұрын
Thx for the tutorial now i understood why we need ref and forwarding ref
@trangnusi13
@trangnusi13 Жыл бұрын
The best explanation of forwardRef that I found. Thanks a lot!
@ahlambeyoud1709
@ahlambeyoud1709 4 жыл бұрын
techsith, you deserve millions of subscribers!! always clear and comprehensive tutorials...keep up the great work you do we truly appreciate it.
@Techsithtube
@Techsithtube 4 жыл бұрын
Thank you so much 😀 Keep on learning!
@MarshallBanananana
@MarshallBanananana Жыл бұрын
Best explanation out of four, I watched so far.
@akashthoriya
@akashthoriya 5 жыл бұрын
waiting for the perfect one and this arrives!
@geraldf6735
@geraldf6735 5 жыл бұрын
A clean video again from you sith... thank you
@theprimecoder4981
@theprimecoder4981 3 жыл бұрын
You helped me a lot I have been facing a issue with ref for weeks now, but it just that I had ref in the the first argument in the object destructive and not in the second argument
@nirmalhasposted
@nirmalhasposted 8 ай бұрын
explained clearly. It is really helpful. Thank you
@deepabhatt2621
@deepabhatt2621 2 жыл бұрын
Thank you soo much for this video Hemil., Finally, it's your video that makes my day.
@gokayarpaci3872
@gokayarpaci3872 5 жыл бұрын
keep on sith. you are doing nice work
@gopideveloper4375
@gopideveloper4375 5 жыл бұрын
Well explained. Thank you
@JaneDoe-ui2bj
@JaneDoe-ui2bj 2 жыл бұрын
this video was sooooo helpful.. I was stuck on the child component ref for hours.. :) -- thank you!!!!!!!
@astraguardian
@astraguardian 3 жыл бұрын
thank you so much. very clear and intuitive way of teaching
@Techsithtube
@Techsithtube 3 жыл бұрын
Glad it was helpful!
@AndrewOnTestingCars
@AndrewOnTestingCars 4 жыл бұрын
Great video thanks very much !
@alex-front-end
@alex-front-end 5 жыл бұрын
Awesome as usual. Cheers!
@boopfer387
@boopfer387 2 жыл бұрын
Excellent example thank you sir!
@artemsergiyenko1086
@artemsergiyenko1086 2 жыл бұрын
Brilliant! Thank you
@rajatshrivastava879
@rajatshrivastava879 3 жыл бұрын
Best on Refs.
@veeracs
@veeracs 4 жыл бұрын
Nice one! just in time...
@J-ko8ig
@J-ko8ig 4 жыл бұрын
Helped me a lot .. thank you 👍
@datoubi
@datoubi 4 жыл бұрын
thanks! taught me exactly what I wanted :)
@Techsithtube
@Techsithtube 4 жыл бұрын
Great to hear!
@showduhtung
@showduhtung 4 жыл бұрын
thanks this was a great video!
@rajshrishrimal2653
@rajshrishrimal2653 4 жыл бұрын
Superb video 💥💥💥
@sandeshbirwadkar2384
@sandeshbirwadkar2384 4 жыл бұрын
Nice video!
@krishnayallapanthula
@krishnayallapanthula 5 жыл бұрын
you explained it very well..
@persoulrpg
@persoulrpg 5 жыл бұрын
I don't really get the point of forwardRef since you can simply pass ref using different property name, eg. myRef and you don't really need no fancy forwardRef for that.
@phamvietnguyenduy6904
@phamvietnguyenduy6904 Жыл бұрын
Thanks, it's very helpfull
@kirancm5165
@kirancm5165 4 жыл бұрын
Best Explained
@gosinP
@gosinP 3 жыл бұрын
Thank you.
@psmolak
@psmolak 3 жыл бұрын
Clear explanation, thanks!
@Techsithtube
@Techsithtube 3 жыл бұрын
Pawel, Glad it was helpful!
@Fatima-ie5kj
@Fatima-ie5kj 3 жыл бұрын
nice - thankyou
@Rahulsecret
@Rahulsecret 4 жыл бұрын
Just a little bit more context around forward ref in practice side would have been great... Otherwise its awesome
@rtorcato
@rtorcato 4 жыл бұрын
when you click or keydown the event that is passed contains a reference called current target. No need to use refs for forms. To set focus for first element in form you can use ref.
@doogdoogdoogdoogdoogdoog
@doogdoogdoogdoogdoogdoog 3 жыл бұрын
Really useful, thanks so much.
@daemperador123
@daemperador123 4 жыл бұрын
Thank you, your video helped me a lot
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad it helped
@jilherme
@jilherme 2 жыл бұрын
Great video!!
@kranthikumar5215
@kranthikumar5215 2 жыл бұрын
Superman 🥰
@Seacrest.
@Seacrest. 3 жыл бұрын
thank you
@himanshushekhar3694
@himanshushekhar3694 3 жыл бұрын
awesome
@abdelrahmanmagdy8946
@abdelrahmanmagdy8946 3 жыл бұрын
thank you alot
@rkgrap
@rkgrap 3 жыл бұрын
You made this so simple, thank you so much
@nanasarathi
@nanasarathi 5 жыл бұрын
Awesome... Well explained... Thanks
@Techsithtube
@Techsithtube 5 жыл бұрын
Thanks for watching Narendra.
@goffredo81
@goffredo81 5 жыл бұрын
Nice video, how would you implement the focus based on the length of the text and not on the key event? Thank you.
@nickshotts3988
@nickshotts3988 2 жыл бұрын
You have an accessibility issue here. Hitting enter on a form field is expected to submit the form, NOT proceed to the next field. This is a good tutorial on useRef, but it is incorrect in terms of accessibility. You can learn more in the MDN docs.
@mi-2453
@mi-2453 4 жыл бұрын
Thank you very much..
@gabrielfono844
@gabrielfono844 4 жыл бұрын
thanks so much do we need to learn class component again because I am building all my application with hooks and I was wondering if I might get asked about class component at my upcoming interview just curious to know what yoiu think since I learnt class and hook from your channel thanks I look forward to hearing from you back.
@brenocristovaorocha
@brenocristovaorocha 4 жыл бұрын
very good!
@F4ILCON
@F4ILCON 3 жыл бұрын
What if you have huge form, with multiple inputs, what is the best practice create useRef and functions for each element, that does not seem practical, any ideas?
@FrontLineXDS
@FrontLineXDS 3 жыл бұрын
Anyway to make this work with Typescript? the Input has type conflicts with what React.forwardRef() expects as an argument
@msea5654
@msea5654 3 жыл бұрын
is there possible way to explain to forwardRef when you have a dynamic list and you want to target the child component to change some property when an event is triggered
@vignesh_m_1995
@vignesh_m_1995 3 жыл бұрын
Why did it fail when we pass the refs through usual props to the child component? Why do we need forwardRef instead of passing it as usual props?. Any specific reasons for that??
@azharponani
@azharponani 4 жыл бұрын
Hi What abt using multiple refs for the same element or component... Like one for local use within the component.. And other for forwarding to the parent component? Is this possible?
@saitejagatadi9711
@saitejagatadi9711 3 жыл бұрын
Hemil, Can you do a short video on Higher Order Components that uses only function components
@mannumannu9200
@mannumannu9200 3 жыл бұрын
Most developers like render props & custom hooks instead hoc because it's hard to track code when using hoc
@the_street_coder4433
@the_street_coder4433 2 жыл бұрын
which vscode theme did you use in these video?
@sumeetprajapati15
@sumeetprajapati15 5 жыл бұрын
Please share your views on, what's the future of php with javascript growing so rapidly.
@Techsithtube
@Techsithtube 5 жыл бұрын
these days , php is used for smaller sites , but for any thing enterprise level , its usually something else. JavaScript is growing more and more.
@muscaiu
@muscaiu 4 жыл бұрын
What if i want to pass ref from a hoc to a Component?
@kishorepantra9769
@kishorepantra9769 2 жыл бұрын
here we are exporting forwardInput from input.js file but in app.js we are importing input not forwardInput how is this working
@saurabrakshit405
@saurabrakshit405 2 жыл бұрын
Can you bother a little to make a vedio on how to send refs from child to parent , it will be appreciated a lot .
@maheshmahi5455
@maheshmahi5455 3 жыл бұрын
Hi sir, I have a case where i used connect method from redux and made a component with React.forwardRef and at the same time i made this component connected to store via this connect method and when i pass a ref to this component actually im unable to access that ref, i know its kinda HOC and how to get that ref from connect ?
@TusharBorawake
@TusharBorawake 4 жыл бұрын
Hi, Can you please make video in which parent component can have access it's child component and grandchild component methods. I was stuck in my real time project. Using react hooks and class component.
@Techsithtube
@Techsithtube 4 жыл бұрын
Tushar , I do have a video on component communication which explains just that. Its using classes but the concept should be the same.
@alexcaissy3257
@alexcaissy3257 3 жыл бұрын
Just noticed a simple thing, could you have done one function for the onKeyDown handlers, and pass the ref as a parameter? Then in the function, just do a switch on the param! You wouldn't have to rewrite the same function three times !!
@temzeks
@temzeks 2 жыл бұрын
Maybe he did it so it would be obvious to viewers. Tutorials do not need to follow DRY principles to explain things like this
@cody._.--._.--.
@cody._.--._.--. 4 жыл бұрын
I saw another video that says useRef just holds any value you want whether it be an object or number or whatever. How is that different than useState? Could you store the field ref in state? On the field: ref=>{(ref) => {setMyRefs( ... spread stuff, myRefs.firstName: ref, next state blah )}}.
@SheikhAmeen
@SheikhAmeen Жыл бұрын
When update a state value, the component re-renders. When you update a ref value, it doesn't trigger a re-render.
@jiwachhetri4165
@jiwachhetri4165 2 жыл бұрын
What if the function Input was within the App.js file?? How can you export without using export default??
@Techsithtube
@Techsithtube 2 жыл бұрын
you dont always have to use export default. you can simply use export but in that case you have to have import using "import { module } from " syntax
@egilmorstu
@egilmorstu 4 жыл бұрын
what vs code extension that convert => into arrow?
@bhushanjagtap7382
@bhushanjagtap7382 4 жыл бұрын
Thanks..
@abc7089
@abc7089 4 жыл бұрын
50/5000 Why couldn't it be done that way?: ... return( ) and inside Input: const Input=({firstNameRef)=>{
@CameronWilby
@CameronWilby 4 жыл бұрын
Great job, thank you!
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad it was helpful!
@shyamsoni5389
@shyamsoni5389 3 жыл бұрын
Hi, I am using this.props.history.push({ pathname:`some path`, state:{ object :object} }) ; on handleSubmit click And reading the data into routed component like this.props.location.state.objectName.field This is working fine when I am using BrowserRouter even when i refresh the page i get the values on page BUT when I am using Hashrouter and I refresh the page I get error saying Can not read properties of undefined Please help
@Techsithtube
@Techsithtube 3 жыл бұрын
HashRouter doesnt support certain things . I would suggest using BrowserRouter instead
@shibnathroy106
@shibnathroy106 5 жыл бұрын
Sir Love your content. *Video Request :* Can you please make a video on your youtube journey and how it has changed your life? I am not asking about financial gains. The positive changes that happened in your life for example opportunities, etc. Thank You.
@singlebw4065
@singlebw4065 4 жыл бұрын
stepBelow = (e, numInp) => { let count = 0; if(e.key === 'Enter'){ for (let i of e.currentTarget) { count++; if (i.name === e.target.name) { if (count < numInp) break; else count = 0; } } e.currentTarget[count].focus() } }
@hariharanb201
@hariharanb201 4 жыл бұрын
How can we do multilevel "forwarding ref" Parent
@nikolay.kupstas
@nikolay.kupstas 4 жыл бұрын
Just pass this ref to your SubChild
@ashishmangla221
@ashishmangla221 4 жыл бұрын
why my page got refresh on enter ?
@Techsithtube
@Techsithtube 4 жыл бұрын
Share your code. it should not have refreshed.
@maheshveez627
@maheshveez627 5 жыл бұрын
Could you make a udemy a course on MERN stack
@Techsithtube
@Techsithtube 5 жыл бұрын
Next week i am releasing a course on React Hooks. I might go for MERN stack afterwards.
@maheshveez627
@maheshveez627 5 жыл бұрын
@@Techsithtube Thank you sir
@newsentertainment1550
@newsentertainment1550 3 жыл бұрын
1000th like
@shireenkhan7569
@shireenkhan7569 3 ай бұрын
11:47 forwarded ref
@andrews13
@andrews13 Жыл бұрын
5:30
@tipfertilizer4595
@tipfertilizer4595 2 жыл бұрын
techshitt
@Pareshbpatel
@Pareshbpatel 6 ай бұрын
{2024-03-22}
@kamleshkumar-vm8cj
@kamleshkumar-vm8cj 3 жыл бұрын
Not given a deep concept.. only he focused on English spoken language
@nishantnimish7825
@nishantnimish7825 4 жыл бұрын
forwardRef explanation was not good
@animanoir
@animanoir 4 жыл бұрын
rip my ears.
useEffect react hook tutorial
15:20
techsith
Рет қаралды 36 М.
React Refs and DOM
21:43
techsith
Рет қаралды 72 М.
Every parent is like this ❤️💚💚💜💙
00:10
Like Asiya
Рет қаралды 20 МЛН
React useRef and forwardRef in depth
10:32
Fullstack Simplified
Рет қаралды 25 М.
React router with hooks ( useHistory useParam  useLocation )
15:56
Never Forget React forwardRef Again
9:33
Coding in Public
Рет қаралды 19 М.
React.memo, useMemo, and useCallback Optimizations
22:09
Code Bushi
Рет қаралды 44 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
React unit testing with Jest & React-testing-library
23:49
techsith
Рет қаралды 391 М.
React Hooks: Advanced Hooks
20:52
Harry Wolff
Рет қаралды 87 М.
HOC or Higher Order Component in ReactJS
15:23
Studytonight with Abhishek
Рет қаралды 4,9 М.
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 103 М.