Never Forget React forwardRef Again

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 81

  • @alinikpey5797
    @alinikpey5797 Рік тому +13

    Watching 10 video to understand what is userRef and forwardRef and why it is called ref untill i heard the answer from you. Thank you. that was a nice explanation

    • @CodinginPublic
      @CodinginPublic  Рік тому +1

      That’s so kind! Glad it was such a help! Thanks!

  • @raldskie23
    @raldskie23 Рік тому +11

    This is the clearest explanation of forwardRef ive ever watched and learned. Just straight up to the point, with proper context to the premise. 🔥

    • @CodinginPublic
      @CodinginPublic  Рік тому

      So glad it was a help! I find that my clearest videos are the ones that come out of errors I make because it forces me to get to the bottom of why things are the way they are. Glad it was a help to you, too!

  • @SouravDuttaROCKSTAR
    @SouravDuttaROCKSTAR Рік тому +5

    One of the best explanation for forwardRef. Short yet precise.💯

    • @CodinginPublic
      @CodinginPublic  Рік тому +3

      Glad it was a help! Thanks for saying something!

  • @akash-kumar737
    @akash-kumar737 Рік тому +2

    Very well explained I always wondered how forwardRef work.
    Cheers 🍻 mate.

  • @JamesQQuick
    @JamesQQuick Місяць тому

    Very helpful, thank you!!

  • @grant_vine
    @grant_vine Рік тому +2

    Nice overview and so simply shown

  • @prashlovessamosa
    @prashlovessamosa Рік тому +4

    Thanks for sharing please make more react stuff.

  • @morchellemusic2829
    @morchellemusic2829 11 місяців тому +1

    Thanks for the explanation, very clear and concise

  • @godofwar8262
    @godofwar8262 Рік тому +2

    Thank you finally a react video

  • @seelvek6550
    @seelvek6550 3 місяці тому

    Thank Chris! Really great explanation!

    • @CodinginPublic
      @CodinginPublic  3 місяці тому

      Glad you found it helpful!

    • @seelvek6550
      @seelvek6550 3 місяці тому

      @@CodinginPublic I did indeed. However, also in meanwhile I found to realise that forwardRef is to be deprecated soon and refs should be passed as props.

  • @yutsacarm8021
    @yutsacarm8021 5 місяців тому

    Omg !!!!! This is the. Best explanation of useRef video !!!

  • @__greg__
    @__greg__ 10 місяців тому

    This was a great explanation, thanks for sharing!

  • @chihuhahuana4863
    @chihuhahuana4863 6 місяців тому

    this video was actually so cool. thanks man!

  • @osifojohn1513
    @osifojohn1513 5 місяців тому

    Love this video, you cleared all my doubts.

  • @ahtshamsaleem2970
    @ahtshamsaleem2970 6 місяців тому

    keep making more videos like these
    i loved it

  • @DashFactsCentral
    @DashFactsCentral 9 місяців тому

    Very beautifully explained! Thanks alot!

  • @RandomMcLain
    @RandomMcLain Рік тому +1

    🎯 Key Takeaways for quick navigation:
    00:34 🤖 React relies on createElement to generate elements in the virtual DOM.
    02:26 🛡️ useRef helps bridge the gap between the virtual DOM and the actual DOM for direct access.
    03:22 💼 Understanding when to use forwardRef: when a component needs access to the actual DOM node, not just the virtual DOM.
    05:14 🛡️ How to implement forwardRef in JavaScript and TypeScript, passing the ref down to child components.
    08:30 🤖 Utilizing the children prop for dynamic content within a component.
    Made with HARPA AI

  • @sahilrathod3930
    @sahilrathod3930 11 місяців тому +1

    Great explanation... ❤

    • @CodinginPublic
      @CodinginPublic  11 місяців тому

      Thanks for saying something! Glad it was a help!

  • @mounis
    @mounis Рік тому +1

    Sorry for the out of context question, which font do you use?
    And BTW amazing explanation.

    • @CodinginPublic
      @CodinginPublic  Рік тому

      No worries. Cascadia code. Free font by Microsoft.

  • @EduardoOliveira-jf1tk
    @EduardoOliveira-jf1tk Місяць тому

    Amazing explanation! Thank you very much. I'll keep following your content. +1 sub 🥳

  • @Aaronmoreno
    @Aaronmoreno 10 місяців тому

    So clear! I’m won over. I subbed

  • @sandiladhikari7903
    @sandiladhikari7903 4 місяці тому +1

    why can't we use just another variable instead of ref ? I mean, in the Form component, we pass another variable, say 'inputRefVar' whose value would be {inputRef}. now inside the component in the input element, we set ref={inputRefVar}. wouldn't it work ? we could still have the parent control it right ? why forwardRef ?

    • @OranJuno
      @OranJuno 13 днів тому

      This is the question that it seems no one tries to explain

  • @coderkashif
    @coderkashif 3 місяці тому

    nice understading

  • @K.Huynh.
    @K.Huynh. Рік тому

    thank for sharing! So cool 😎

  • @ahmadm.hawwash3931
    @ahmadm.hawwash3931 4 місяці тому +1

    Great video, thanks for sharing!
    Can't we pass it as another prop name? I mean we could pass as reference instead of ref. Could that solve the issue?

    • @OranJuno
      @OranJuno 13 днів тому

      This is the question no one seems to try to explain.

  • @frederikjorgensen94
    @frederikjorgensen94 7 місяців тому

    Thanks!

  • @OranJuno
    @OranJuno 13 днів тому

    5:15 "well you might think that you can pass refs like props like this, but that's not how they work"
    But why not though? That's the answer that no one seems to explain. It does actually work, but not always. Why?

  • @ronaldpaek
    @ronaldpaek Рік тому +1

    I have a question about IDE's I remember watching some of your older videos and you used to use Nova IDE, just wanted to hear why you switched back to VS code I haven't seen many people use Nova IDE so I would love to hear about the Pros / Cons of Nova vs VS Code.

    • @CodinginPublic
      @CodinginPublic  Рік тому +1

      I haven’t used nova in a while, so I’m sure they’re much better now. I loved it but between viewers on the channel wanting to see VSCode and the lack of support for things like Astro originally, I switched.

    • @ronaldpaek
      @ronaldpaek Рік тому

      that makes sense, I feel like most viewers/supporters will be using vs code 😆@@CodinginPublic

  • @adarsh-chakraborty
    @adarsh-chakraborty Рік тому

    Thanks

  • @VishalSharma-rn7mt
    @VishalSharma-rn7mt 11 місяців тому

    Awesome

  • @mohammadalrefaai4377
    @mohammadalrefaai4377 10 місяців тому

    Actually the form could have one responsibility it could have the form and their inputs also the behavior of the inputs, it's cleaner 😊

    • @CodinginPublic
      @CodinginPublic  10 місяців тому +1

      Could you explain more what you mean here?

  • @KrunalShrimali-o4q
    @KrunalShrimali-o4q Рік тому

    can we forward multiple refs at once to a component?

    • @CodinginPublic
      @CodinginPublic  Рік тому +2

      No, and something I should have mentioned (at least I don’t think you can). Typically you componetize individual inputs or items that need a ref (so single elements) when forwarding refs.

    • @Kraszer
      @Kraszer 4 місяці тому

      Just pass refs as normal props. It works on older React versions too like 17.0.0. I don't understand why to even use fowardRef.

  • @nicus1504
    @nicus1504 4 місяці тому

    You CAN pass refs directly as props

    • @CodinginPublic
      @CodinginPublic  4 місяці тому

      You can now in react 19. :)

    • @Kraszer
      @Kraszer 4 місяці тому

      @@CodinginPublic Not true, you could pass refs as props before, and it just worked. I tested in on React 17.0.0. I spend some time on internet and still really didn't understand why fowardRef exists.

  • @ayushnautiyal9469
    @ayushnautiyal9469 9 місяців тому

    What about multiple refs. If we want to pass multiple refs than how we use forwardrefs.

    • @CodinginPublic
      @CodinginPublic  9 місяців тому

      You don't :) The idea is to have each component as it's own standalone. So you'd have a single input with a forwardRed that you would embed in a form that might have another forwardRef, etc.

    • @Kraszer
      @Kraszer 4 місяці тому

      Just pass refs as normal props. It works on older React versions too like 17.0.0. I don't understand why to even use fowardRef.

  • @mrlectus
    @mrlectus 8 днів тому

    Can we put ref in context

  • @hos7012
    @hos7012 Місяць тому

    Most painful thing in react
    Hopefully in v19 will be removed

  • @anhdunghisinh
    @anhdunghisinh 7 місяців тому

    And now they ditch forwardRef :v

  • @Pareshbpatel
    @Pareshbpatel 8 місяців тому

    {2024-03-22}

  • @ChristinaCodes
    @ChristinaCodes Рік тому

    This is by far the best forwardRef video I’ve ever seen, it finally makes sense 🥲 Thank you so much for this.

    • @CodinginPublic
      @CodinginPublic  Рік тому +1

      You’re welcome! Glad it was such a help! That’s so…

  • @carlandres3319
    @carlandres3319 9 місяців тому

    Thanks