React Refs Explained with Examples | React useRef Tutorial

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024

Комментарии • 39

  • @CodingWithChaim
    @CodingWithChaim  4 года назад +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: ruclips.net/user/codingwithchaim

  • @SlimAndCherryTravel
    @SlimAndCherryTravel 3 года назад +1

    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. :-)

  • @PawanKolhe
    @PawanKolhe 3 года назад +1

    The best explanation of Refs I could find on RUclips. Thanks.

  • @ikibkilam8383
    @ikibkilam8383 3 года назад +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!

  • @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 ❤

  • @naveenkalburgis
    @naveenkalburgis 4 года назад +1

    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 года назад +1

    Keep it up bro really helpful !!! Headsup from India !!!!

  • @tomasgilamoedo8301
    @tomasgilamoedo8301 2 года назад

    Excellent explanation, solid and detailed! really appreciated

  • @haciendadad
    @haciendadad 11 месяцев назад

    Very helpful! Thanks!

  • @georgevinueza7249
    @georgevinueza7249 3 года назад

    Thanks for the quality content Chaim!

  • @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

  • @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.

  • @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 3 года назад

    Great video man. Thank you!

  • @mathearts9739
    @mathearts9739 3 года назад

    awesome explanation god bless you

  • @romantyniv5381
    @romantyniv5381 3 года назад

    Brilliant videos. Don't unserstand why not so many subscr. People ! hit the button to subscribe ! Thank you man!

  • @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.

  • @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 года назад +2

      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

  • @silicongamingm1
    @silicongamingm1 7 месяцев назад

    nice video

  • @r-i-ch
    @r-i-ch 4 года назад +1

    Why not for the focus?

    • @CodingWithChaim
      @CodingWithChaim  4 года назад +1

      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.

  • @bhavyabansal1143
    @bhavyabansal1143 Год назад

    Great video, only request is to please go slow. You are very fast :)

  • @simongirouxportelance4956
    @simongirouxportelance4956 4 года назад

    I used a Ref to keep an Interval, because I didn't want multiple interval !

  • @r-i-ch
    @r-i-ch 4 года назад

    Can you change the value of a ref?

    • @CodingWithChaim
      @CodingWithChaim  4 года назад +1

      Rich Werden yes absolutely refs are completely mutable

  • @iliketocode6986
    @iliketocode6986 4 года назад

    does this cover ref forwarding?

  • @learnmaziyyah473
    @learnmaziyyah473 4 года назад

    FeathersJS Please

  • @omrizilberstein2828
    @omrizilberstein2828 3 года назад

    Great video! love from israel

  • @okonkwo.ify18
    @okonkwo.ify18 2 года назад

    Why did u keep ur face as if it’s rocket science? 😂 it’s not