React Refs Explained with Examples | React useRef Tutorial

  Рет қаралды 7,571

Coding With Chaim

Coding With Chaim

Күн бұрын

Пікірлер: 39
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
Whats up everybody? Thanks for watching! If you enjoyed the video, please be sure to drop a like it really helps. Also, if you have not already done so, be sure to subscribe to the channel so you never miss an upload. You can subscribe here: kzbin.info
@aruchgupta
@aruchgupta 2 жыл бұрын
You're the coolest React mentor out there! Thank You. And so underrated!
@PawanKolhe
@PawanKolhe 3 жыл бұрын
The best explanation of Refs I could find on KZbin. Thanks.
@SlimAndCherryTravel
@SlimAndCherryTravel 3 жыл бұрын
I'm not sure what it is about these videos, but you are providing the kind of learning I've been looking for with React. I can look at tutorials all day and nothing sinks in, almost like the teacher is trying to save me from the difficult parts, but I walk away never actually knowing how the hell anything actually works. Far out man, thank you. Well done. I looks forward to more of these. In the meantime, I've got a bit of a back-catalogue of yours that I need to work through. :-)
@ikibkilam8383
@ikibkilam8383 4 жыл бұрын
I never really understood useRef, though I have used it a few times. This is the best explanation of what it does. Thank you very much for this awesome explanation!
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
Thank you!!
@ahmed-osama2022
@ahmed-osama2022 Жыл бұрын
Thanks a lot for explaining this concept very well, I loved you way you teach
@smellycyborg3133
@smellycyborg3133 3 жыл бұрын
brilliant. you're explaining everything in such good detail. and because i've been coding for a year i understand it. i'm switchign for game development to dev
@Moon-nk7gv
@Moon-nk7gv Жыл бұрын
I am so lucky to find your videos! I don't think i am smart But u really make me understand almost everything you said! You are such an amazing teacher! Keep it up the good work. You have no idea potentially how many lives You are saving ❤
@tomasgilamoedo8301
@tomasgilamoedo8301 3 жыл бұрын
Excellent explanation, solid and detailed! really appreciated
@tejasnikam3287
@tejasnikam3287 4 жыл бұрын
Keep it up bro really helpful !!! Headsup from India !!!!
@pritulkhan1395
@pritulkhan1395 4 жыл бұрын
You got a lot of potential with this channel, just wanna say keep it up -- you have earned a sub. Cheers from Bangladesh
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
Thank you! I appreciate that
@haciendadad
@haciendadad Жыл бұрын
Very helpful! Thanks!
@naveenkalburgis
@naveenkalburgis 4 жыл бұрын
Good tutorial. Instead of using useRef for focus.. you could simply use autofocus attribute on input text JSX element for this first example.
@girugaymesh
@girugaymesh 2 жыл бұрын
I'm still kind of new to react and I only get to work on my project in my free time, so I need all the help I can get: I have a problem with useRef() that is driving me insane. I slapped a click listener onto a bunch of GenericComponent swhich attaches a "wraparound" Component to the click component. What I want to happen is: before click: after click: In my useEffect() hook, I try to access the currently clicked Wraparound- and GenericComponent, but it does not seem to catch up. Aftter my first click, the ref will be undefined. After my second click, the console output will be the first clicked element. I feel like I am not getting a crucial part about how useEffect() works here.. Any help is greatly apprecianted.
@georgevinueza7249
@georgevinueza7249 3 жыл бұрын
Thanks for the quality content Chaim!
@emekaokonkwo626
@emekaokonkwo626 Жыл бұрын
Thanks for this video by the way really needed, but so when you had "const time = useRef(Date.now())" and left the "ref={inputRef}" in the "input" tag, it still worked???
@CandyMoney1000
@CandyMoney1000 4 жыл бұрын
Great video man. Thank you!
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
You are most welcome
@mathearts9739
@mathearts9739 3 жыл бұрын
awesome explanation god bless you
@mr.RAND5584
@mr.RAND5584 4 жыл бұрын
I want to desttructure html on that useref coz i want to use the get element by tag name. I have multple 50s input type text dynamically created by map function.
@r-i-ch
@r-i-ch 4 жыл бұрын
Why not for the focus?
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
Yea that absolutely can work, but the idea is that sometimes you want to set focus to an input programmatically based on some conditions. Also, the idea of the example is more about showing that in react you need refs when you want interact with the actual dom.
@iliketocode6986
@iliketocode6986 4 жыл бұрын
does this cover ref forwarding?
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
No I didn’t include that in the video
@Gandolfof
@Gandolfof 4 жыл бұрын
Thanks you! Awesome video explaining refs. But why don't you simply use this: useEffect(() => { const time = Date.now(); setInterval(() => { if (moment.diff(time, "minutes") > 1) { alert("you have ...") } }, 1000 * 60); }, []) Isn't it simpler and better? I don't get it why someone would prefer react refs approach over this.
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
This is a great question! I think maybe my example was a little lacking. The ref would be the better choice if you want access to the value in more than one place within the component. In your case it would be scoped to only within the useEffect
@r-i-ch
@r-i-ch 4 жыл бұрын
Can you change the value of a ref?
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
Rich Werden yes absolutely refs are completely mutable
@simongirouxportelance4956
@simongirouxportelance4956 4 жыл бұрын
I used a Ref to keep an Interval, because I didn't want multiple interval !
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
indeed! very good point
@learnmaziyyah473
@learnmaziyyah473 4 жыл бұрын
FeathersJS Please
@silicongamingm1
@silicongamingm1 11 ай бұрын
nice video
@bhavyabansal1143
@bhavyabansal1143 2 жыл бұрын
Great video, only request is to please go slow. You are very fast :)
@romantyniv5381
@romantyniv5381 3 жыл бұрын
Brilliant videos. Don't unserstand why not so many subscr. People ! hit the button to subscribe ! Thank you man!
@omrizilberstein2828
@omrizilberstein2828 4 жыл бұрын
Great video! love from israel
@CodingWithChaim
@CodingWithChaim 4 жыл бұрын
Thank you! I miss Israel
@okonkwo.ify18
@okonkwo.ify18 2 жыл бұрын
Why did u keep ur face as if it’s rocket science? 😂 it’s not
Immer Tutorial | Immer and React Match Made in Heaven
10:55
Coding With Chaim
Рет қаралды 9 М.
Refs in React: from access to DOM to imperative API
12:53
Developer Way
Рет қаралды 4,8 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
Never Forget React forwardRef Again
9:33
Coding in Public
Рет қаралды 24 М.
React JS #12 Ссылки (Refs)
9:47
webDev
Рет қаралды 18 М.
React Fundamentals in 30 Minutes
31:22
Coding With Chaim
Рет қаралды 10 М.
A Trick Every React Developer Should Know: Ref Forwarding
9:08
Josh tried coding
Рет қаралды 21 М.
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 119 М.
useRef hook in reactjs | Easiest way
19:44
Hitesh Choudhary
Рет қаралды 84 М.
Learn useRef in 11 Minutes
10:20
Web Dev Simplified
Рет қаралды 656 М.
Scroll to mapped Components CORRECTLY in React 🤯 - Mapping react refs
22:46
Code with Ania Kubów
Рет қаралды 34 М.
Understanding how the useRef Hook works in React
23:51
LogRocket
Рет қаралды 8 М.
ALL React Hooks Explained in 12 Minutes
12:21
Code Bootcamp
Рет қаралды 177 М.