React Hooks useRef Tutorial

React Hooks useRef Tutorial

Ben Awad

5 лет назад

97,167 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@CaioUechi
@CaioUechi - 10.05.2023 07:44

damn, you are too fast. I guess Im too dumb for this hook atm lol

Ответить
@cali4484
@cali4484 - 04.12.2022 07:50

Disliked 👎

Ответить
@hamidshoja3829
@hamidshoja3829 - 21.10.2022 17:09

Hey Ben, well done, good use cases, just to let everybody knows, the unmount warning use case is resolved in React 18 , no use case anymore so.

Ответить
@AbhishekSharma-mm6ld
@AbhishekSharma-mm6ld - 22.07.2021 22:05

Thanks for highlighting all those things with useRef most of the time I only use it for dom reference only.

But Even though as per the last part I would have still gone for clearTimout during the memory clean up :)

Ответить
@herrklaus
@herrklaus - 22.07.2021 13:27

Thank you, Ben.

Ответить
@phantazzor
@phantazzor - 11.06.2021 13:24

nice , you going really fast but nice video

Ответить
@pratikkamath8423
@pratikkamath8423 - 06.04.2021 19:52

Great video Ben! Pretty concise and well-explained :)

Ответить
@adrisongomez8454
@adrisongomez8454 - 04.04.2021 22:23

That moment when you realize that you are not the only one that feel loose trying copy and paste using VIM in a Mac.

Ответить
@vaasudhand3200
@vaasudhand3200 - 09.02.2021 22:16

For the second useCase, can't we just use a "let variable" to maintain some data across re-renders. Obviously that variable will not be used anywhere, where it can cause a re-render?

Ответить
@dawid_dahl
@dawid_dahl - 26.01.2021 10:48

The final part of the video was gold for me, I’m working with some component transition animations and I have that error. Thanks!

Ответить
@rohandevaki4349
@rohandevaki4349 - 19.12.2020 09:20

your code on github seems like it is the finished code, but not initial code. please provide the initial code

Ответить
@chrisarcher9907
@chrisarcher9907 - 01.10.2020 19:06

any thoughts on how to provide focus on mapped inputs?

Ответить
@javierzapien314
@javierzapien314 - 01.10.2020 00:48

I don’t see how the hello component is re-rendering as you type??

Ответить
@joshpeterson1004
@joshpeterson1004 - 17.09.2020 23:38

If you pass [] into useEffect and then set isCurrent.current to false inside, why isn't it set to false on first render?

Ответить
@ateebahmed2237
@ateebahmed2237 - 17.09.2020 19:14

Mast video banai h, maza agya !

Ответить
@jorgeramirezsandin9358
@jorgeramirezsandin9358 - 15.09.2020 10:53

I was not understanding most part of your videos as I was watching them being a total beginner to React, but I've come here after a month and they are very clarifying. Thank you for taking your time on doing this.

Ответить
@julianb.8749
@julianb.8749 - 11.09.2020 15:44

deep!

Ответить
@raptus9115
@raptus9115 - 06.09.2020 18:54

Sorry, but ref's is the worst idea the React team has come up with, so what if I need to detect the widths and heights of 20 elements? I have to add refs for 20 elements? Insanity. I love React but anything relating to DoM manipulation quickly becomes a clusterfuck of ref's and is tragically unmaintainable.

A better solution needs to be on the table.

Ответить
@kishorrathva4097
@kishorrathva4097 - 26.08.2020 13:40

in my case 'Hello render ' console twice every time i type like if i type 'a' it console 'Hello render 1' and Hello render 2' , can any one help?

Ответить
@kirankandula2779
@kirankandula2779 - 28.07.2020 05:12

Thanks for the video. The usecases considered here are very helpful.

Ответить
@manthenagowtham9437
@manthenagowtham9437 - 24.07.2020 18:23

I have a code which is multiple popover in material ui in react class components. I need that code to be in react hooks. Can you help me? If so please reply me I'll send the code link.

Ответить
@the_derpler
@the_derpler - 26.04.2020 09:13

Thanks. This is a good video. It helped me clear up some misconceptions I had about refs.

Ответить
@GlenBondMogane
@GlenBondMogane - 29.03.2020 01:37

I've learnt alot to this Playlist... Very well explained and great examples for all use cases

Ответить
@dericbytes
@dericbytes - 08.02.2020 19:26

Really well done. Thanks

Ответить
@tannerbyers6729
@tannerbyers6729 - 06.02.2020 08:43

Awesome tutorial! Really helped! Subscribed :)

Ответить
@mayankketkar3450
@mayankketkar3450 - 28.01.2020 00:00

What does imperative calling imply? I get the definition however i am trying to distinguish that from using props to propagate changes

Ответить
@AnilPai
@AnilPai - 15.01.2020 11:38

Thank you so much for your react hooks tutorial videos. I stumbled upon your video when I was searching for useRef usage, looks like you have the best explanation of all. Including all the different use cases. I would suggest you to update the React docs with your examples.

Ответить
@ZhDinerstein
@ZhDinerstein - 19.11.2019 09:29

Love these videos! Precise and very easy to follow.

If possible, please increase the zoom on your IDE in the future. Can be difficult to read sometimes while viewing on a phone.

Ответить
@DiogoLessa
@DiogoLessa - 22.10.2019 05:18

Hi, Ben! Could you share with us some extensions you use in vscode to speed up your coding? I can see you have some cool stuff around... We'd appreciate!

Ответить
@NoferatuAlex
@NoferatuAlex - 11.10.2019 07:24

Waw I did not know useRef is this good, thanks!

Ответить
@oorangecchicken
@oorangecchicken - 07.10.2019 02:19

Interesting... but how does useRef(0) not reset back to “0” every time the component re-renders? Shouldn’t it always render “1” even with the unary (++) operator?

Ответить
@vasupatel6932
@vasupatel6932 - 04.10.2019 17:54

Short and Sweet

Ответить
@kareemsakr41
@kareemsakr41 - 29.09.2019 19:40

Great work. keep it up.

Ответить
@blackzerosrb
@blackzerosrb - 26.09.2019 22:53

Yes, React users forgets JavaScript very quick... 🙂

Ответить
@pjately078
@pjately078 - 03.09.2019 12:16

Do you have any tutorials on creating custom hooks like the useFetch hook in this video?

Ответить
@user-ym2lb2vl2n
@user-ym2lb2vl2n - 18.07.2019 20:39

awsome,useful,perfect,Thank you!

Ответить
@Seb16291629
@Seb16291629 - 13.07.2019 16:18

Clear and concise ! Time for some refactoring !

Ответить
@aashayamballi
@aashayamballi - 12.07.2019 12:50

Thank you so much, it was so clear and concise. Thank you again :)

Ответить
@madebylewis
@madebylewis - 25.06.2019 00:58

You can also utilise a hook with useRef to return a previous value (e.g. prevProps, prevState), pretty neat!

Ответить
@Ko0lHaNDLuKex
@Ko0lHaNDLuKex - 25.06.2019 00:52

Hi Ben, thanks again for an informative video!

A question: what's stopping me using a plain JS variable to ensure the state isn't being updated after unmounting? Like, just saying `let isMounted = true` when the effect is called, checking isMounted before setting any state, and then setting isMounted to false in the cleanup function?

Why do we have to use a ref here?

Thanks!

Ответить
@aqua123670
@aqua123670 - 25.06.2019 00:12

thank you

Ответить
@lilibayo
@lilibayo - 24.06.2019 21:37

For the isCurrent example to ensure we dont call setState on an unmounted component, I have seen some examples that utilizes useState with a variable isMounted. Everything is pretty much the same as the example you provided. Curious as to the difference in using state vs ref to keep track of the isMounted/isCurrent state/var. Is one better or is it just a personal pref?


Thanks!

Ответить
@tomermatmon
@tomermatmon - 24.06.2019 17:36

Great! Thank you!

Ответить
@zhanghedev
@zhanghedev - 24.06.2019 17:12

I am the first one to support you.

Ответить