Тёмный

React Refs Explained with Examples | React useRef Tutorial 

Coding With Chaim
Подписаться 16 тыс.
Просмотров 7 тыс.
50% 1

In this video I explain what refs in react are, and I show 2 examples of how they are useful. Refs are especially useful when you want to interact with the underlying dom node, or when you want to presit data between renders.
If you would like to schedule a mock interview with me, you can email me at
codingwithchaim@gmail.com(opens in new tab) for price and details.
Follow me on Twitter: / codingwithchaim
Subscribe to the channel: www.youtube.co...

Опубликовано:

 

7 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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: ru-vid.com
@PawanKolhe
@PawanKolhe 3 года назад
The best explanation of Refs I could find on RU-vid. 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 3 года назад
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 3 года назад
Thank you!!
@ahmed-osama2022
@ahmed-osama2022 8 месяцев назад
Thanks a lot for explaining this concept very well, I loved you way you teach
@aruchgupta
@aruchgupta Год назад
You're the coolest React mentor out there! Thank You. And so underrated!
@smellycyborg3133
@smellycyborg3133 2 года назад
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 ❤
@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
@tomasgilamoedo8301
@tomasgilamoedo8301 2 года назад
Excellent explanation, solid and detailed! really appreciated
@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.
@tejasnikam3287
@tejasnikam3287 4 года назад
Keep it up bro really helpful !!! Headsup from India !!!!
@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.
@haciendadad
@haciendadad 11 месяцев назад
Very helpful! Thanks!
@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???
@mathearts9739
@mathearts9739 3 года назад
awesome explanation god bless you
@mr.RAND5584
@mr.RAND5584 3 года назад
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.
@CandyMoney1000
@CandyMoney1000 3 года назад
Great video man. Thank you!
@CodingWithChaim
@CodingWithChaim 3 года назад
You are most welcome
@romantyniv5381
@romantyniv5381 3 года назад
Brilliant videos. Don't unserstand why not so many subscr. People ! hit the button to subscribe ! Thank you man!
@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
@bhavyabansal1143
@bhavyabansal1143 Год назад
Great video, only request is to please go slow. You are very fast :)
@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.
@silicongamingm1
@silicongamingm1 7 месяцев назад
nice 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
@iliketocode6986
@iliketocode6986 4 года назад
does this cover ref forwarding?
@CodingWithChaim
@CodingWithChaim 4 года назад
No I didn’t include that in the video
@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
@omrizilberstein2828
@omrizilberstein2828 3 года назад
Great video! love from israel
@CodingWithChaim
@CodingWithChaim 3 года назад
Thank you! I miss Israel
@learnmaziyyah473
@learnmaziyyah473 4 года назад
FeathersJS Please
@okonkwo.ify18
@okonkwo.ify18 2 года назад
Why did u keep ur face as if it’s rocket science? 😂 it’s not
Далее
REACT MEMO vs USECALLBACK vs USEMEMO
13:18
Просмотров 55 тыс.
Первый день школы Катя vs Макс
19:37
🛑 ты за кого?
00:11
Просмотров 48 тыс.
Never Forget React forwardRef Again
9:33
Просмотров 18 тыс.
The Key to Understanding React: Why Keys Matter
6:50
Learn React Hooks: useRef - Simply Explained!
12:42
Просмотров 96 тыс.
React Fundamentals in 30 Minutes
31:22
Просмотров 10 тыс.
React Interview Questions 2020 (7 More Questions)
23:16
Dynamic Refs and State in React
18:02
Просмотров 2,8 тыс.
useRef hook in reactjs | Easiest way
19:44
Просмотров 77 тыс.
ALL React Hooks Explained in 12 Minutes
12:21
Просмотров 121 тыс.