ReactJS Tutorial - 14 - Binding Event Handlers

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2018
  • 📘 Courses - learn.codevolution.dev/
    💖 Support UPI - support.codevolution.dev/
    💖 Support PayPal - www.paypal.me/Codevolution
    💾 Github - github.com/gopinav
    📱 Follow Codevolution
    + Twitter - / codevolutionweb
    + Facebook - / codevolutionweb
    📫 Business - codevolution.business@gmail.com
    In this video, lets learn how to bind event handlers in React components.

ความคิดเห็น • 278

  • @isaacdruin
    @isaacdruin 3 ปีที่แล้ว +109

    "so in this video, I will go over all of them"
    What a legend.

  • @dylanoh3425
    @dylanoh3425 4 ปีที่แล้ว +85

    This channel is definitely underrated. It deserves more attentions!! Great work man.

  • @satisfyingindustrialequipment
    @satisfyingindustrialequipment 5 ปีที่แล้ว +128

    I rarely comment on TH-cam but your tutorial and the way you explain is mind blowing i wish if I can support you financially now, but one day I will when I get a job. Thanks a lot for great content

    • @architectsmusicgroup
      @architectsmusicgroup 2 ปีที่แล้ว +2

      True! Clear and concise! Very helpful.

    • @zeeu
      @zeeu 2 ปีที่แล้ว +3

      I hope you already landed your dream job

  • @Daniel-nb3kk
    @Daniel-nb3kk 4 ปีที่แล้ว +13

    You explain concepts and ideas so well a mere child will understand you. Great job!

  • @toannew
    @toannew 3 ปีที่แล้ว +19

    4:30 why event binding is important
    5:00 use bind()
    6:20 2nd method: use the arrow function
    7:57 3rd method (official and mostly used): binding from constructor
    9:40 4th method: define the trigged function as an arrow function

  • @vinitraut1425
    @vinitraut1425 4 ปีที่แล้ว +293

    4:25 'this' keyword is undefined because this used with a function returns 'window' object on the browser and 'global' object inside nodejs environment. Since 'react strict mode' is enabled, it is returning 'undefined'.

    • @dasunanushka8774
      @dasunanushka8774 4 ปีที่แล้ว +5

      Yes. This is the actual reason it gives undefined.

    • @meghalbisht6768
      @meghalbisht6768 4 ปีที่แล้ว +1

      please elaborate a little

    • @akashgupta1353
      @akashgupta1353 4 ปีที่แล้ว +1

      hey please elaborate more

    • @jatintayal4358
      @jatintayal4358 4 ปีที่แล้ว +13

      arrow functions don't create their own context so there it worked without binding.

    • @pradeepsaravanan4348
      @pradeepsaravanan4348 4 ปีที่แล้ว +152

      @@akashgupta1353 First of all "this" keyword points the Parent element on which it is called . So when you use a Named function with the "this" keyword inside it , it isn't binded to anything at all ..So the control passes to the "Window" element . So the Window element acts as a parent to the Named function . We see "Undefined" here because we use "Strict mode " in Javascript . What Strict Mode does is, if there is a named function( without any Bind method ) it transfers control to the parent element(window element) as i said ..this action is blocked by the strict mode ..So you see "undefined" in there ...However if you take off the strict mode ,you should see it will return the Window object ... The One Stop Solution to all of this is using arrow functions which takes parent element as the Class and not the window object .

  • @TheInfamousAlpha
    @TheInfamousAlpha 4 ปีที่แล้ว +90

    (this) was great explanation

    • @kran399
      @kran399 4 ปีที่แล้ว +2

      haaha yes (this) was

    • @moderncloth682
      @moderncloth682 3 ปีที่แล้ว +4

      this.setState({
      comment: 'Haha, coding joke'
      })

    • @Nikhilsharma-dp9tw
      @Nikhilsharma-dp9tw 3 ปีที่แล้ว +2

      @@moderncloth682 undefined

  • @nishantagrawal6244
    @nishantagrawal6244 3 ปีที่แล้ว +5

    After a hell lot of reading stackoverflow and blogs, I got everything under the same roof and now every single approach seems relatable. Thanks a ton man! God bless you.

  • @souvikkar5515
    @souvikkar5515 3 ปีที่แล้ว +3

    Bruh! the best react tutorial on the whole YT. Small yet detailed videos.

  • @edwinvarghese
    @edwinvarghese 3 ปีที่แล้ว +2

    showed all the mistakes we could possibly make and proceeded to fix all of them one by one. Thanks a ton for this tutorial. You are a legend.

  • @KelleyKouture
    @KelleyKouture 4 ปีที่แล้ว +10

    FinallFinally!!!! A video that actually helped me and explained it so well! Thank you so much!!

  • @taharasheed2096
    @taharasheed2096 3 ปีที่แล้ว +8

    One of the best tutor ( I watched too many tutorials for react but this one is really the best...Even he taught how to deal with logical errors )

  • @ANOTHERWOOK
    @ANOTHERWOOK 3 ปีที่แล้ว +2

    I honestly felt like a dumbass until I stumbled upon your channel. You explain everything in such a chill manner in which I can understand easily... highly underrated!

  • @MrBelleblaas
    @MrBelleblaas 3 ปีที่แล้ว +5

    Absolutely exellent.
    My threshold to continue with React has been set
    from now.
    Thank you very much.

  • @VOLTDOGmusic
    @VOLTDOGmusic 5 ปีที่แล้ว +11

    One of the best teachers on TH-cam, thanks bruddah!

  • @simbarashemaunga5575
    @simbarashemaunga5575 ปีที่แล้ว +1

    It's really great how you give examples for both class based and functional components.

  • @PragnaPresence
    @PragnaPresence 2 ปีที่แล้ว +2

    Most underrated channel with mind-blowing content with clean and crisp explanation. I rarely comment for a tech YT but this channel is beyond amazing. Many wow factors in the explanation and explanation of the reasons behind the regular usage.

  • @maghani.official
    @maghani.official 4 ปีที่แล้ว +6

    I was exactly looking for something like this and honestly I salute you for the way you explained and structured the code for us to learn. I feel like an expert Reactjs Developer after watching this lol

  • @RegularExpression1
    @RegularExpression1 5 ปีที่แล้ว +3

    Excellent brief tutorial that covers topic well in a few minutes time. Thanks.

  • @xavier.antony
    @xavier.antony ปีที่แล้ว +1

    You guys are professional teachers. Awesome..

  • @azar1608
    @azar1608 4 ปีที่แล้ว +3

    What a great explaination man, I understood the basic of react from your course, thanks for sharing

  • @shvideo1
    @shvideo1 5 ปีที่แล้ว

    Excellent comprehensive and clear instruction. Very helpful. Thank you.

  • @ShreyaskarART
    @ShreyaskarART ปีที่แล้ว

    This course so far is the most intuitive one, I'm loving it !

  • @kumarp5632
    @kumarp5632 4 ปีที่แล้ว +2

    You made ReactsJs very simple and clean to understand.. Great Work and Kudos

  • @vishnugajulapalli5305
    @vishnugajulapalli5305 3 ปีที่แล้ว +8

    1. Binding in render
    2. Arrow function in render
    3. Binding in the class constructor
    4. Class property as arrow function

  • @avinashsuntosh8620
    @avinashsuntosh8620 4 ปีที่แล้ว +1

    Vishwas, you rock man! Thanks so much for these beautiful tutorials. Much appreciated.

  • @batulmajid
    @batulmajid 4 ปีที่แล้ว +2

    After long research, i finally find something which satisfies me. Thanks Man!

  • @danishali4665
    @danishali4665 4 ปีที่แล้ว

    One of the best tutorials for Javascript and React library, I must say it`s a great contribution for developer community thankyou so much appreciate it.

  • @priyankas7136
    @priyankas7136 4 ปีที่แล้ว +1

    Yes. This tutorial is amazing. As a beginner I am getting to learn alot. Very good work Mr Vishwas

  • @GeryTeague
    @GeryTeague 7 หลายเดือนก่อน +1

    Great presentation. I would recommend a variation on binding in the constructor. Instead bind on method creation in the class.
    clickHandler = function(){ ... }.bind(this);
    This keeps the binding with the function when it is created.

  • @tungngo2445
    @tungngo2445 4 ปีที่แล้ว

    Your video helps me tremendously. Thank you so much. You are a great teacher

  • @pipertripp
    @pipertripp 4 ปีที่แล้ว +4

    Also, Vishwas, this is an excellent series. Well done mate.

  • @tannerbarcelos6880
    @tannerbarcelos6880 4 ปีที่แล้ว +1

    Best explanation of bind() ! As a Java and C++ guy in school, it was easy to understand this. OOP for the win

  • @aqibsaeed3229
    @aqibsaeed3229 2 ปีที่แล้ว

    Just Excellent and Simplest way of explaining all cases with sequence and basic example. Keep up great work.

  • @sanjeetsahni4998
    @sanjeetsahni4998 5 ปีที่แล้ว

    For beginners this video are must watch.. I got lot of confusion but after watching these videos everything is clear now..

  • @nakimapi
    @nakimapi 3 ปีที่แล้ว +1

    such a clean way of teaching!

  • @StayEmployed
    @StayEmployed 4 ปีที่แล้ว +2

    This is the first video I've seen that effectively explains 'bind(this)' well. Thank you!!

  • @apurvsawant5703
    @apurvsawant5703 4 ปีที่แล้ว +1

    Thank you for providing this content. Great Work.

  • @yaw199
    @yaw199 3 ปีที่แล้ว +1

    I think I need to comment on your videos. You are genius and thanks for such an incredible explanations. You deserve more than 5⭐⭐⭐⭐⭐⭐. I was confused with react ideology till your videos saved me lol. Bravooo!!!

  • @medhapatil1372
    @medhapatil1372 4 ปีที่แล้ว +1

    Thank you so much! Great Tutorial.

  • @AZnuclear
    @AZnuclear 4 ปีที่แล้ว +1

    Congratulations my friend, that was a very good tutorial

  • @johnm7571
    @johnm7571 ปีที่แล้ว

    in 2023 ur videos are the best from all other tutors

  • @ChillCityNaveen
    @ChillCityNaveen 4 ปีที่แล้ว

    This tutorials are very much interested not even single minute am feeling bored and very much detail on each concept thanks my dear.

  • @faruzzy
    @faruzzy 5 ปีที่แล้ว +2

    This is gold!!
    Thanks!

  • @maiaklimenko6614
    @maiaklimenko6614 ปีที่แล้ว

    Thank you for the amazing and simple explanation!

  • @i_am_hugeng4120
    @i_am_hugeng4120 2 ปีที่แล้ว

    You deserve more seubscriber and more viewer Sir, i started this reactJS Tutorial series to prepare my self in learning your nextJS Tutorial series. Thank you so much.

  • @Shahidulidseacademy
    @Shahidulidseacademy 3 ปีที่แล้ว

    This tutorial is very useful for me, Thank you Codevolution !

  • @lintstudios3072
    @lintstudios3072 2 ปีที่แล้ว

    Great video! Helped me so much! keep up the great work.

  • @alexsampaio9198
    @alexsampaio9198 3 ปีที่แล้ว +1

    You're a legend, man. Keep it up.

  • @mohdsalim3790
    @mohdsalim3790 3 ปีที่แล้ว

    sir i like your way of teaching...you explain every concept in a easy way

  • @Paparoo24
    @Paparoo24 2 ปีที่แล้ว +3

    Arrow functions are very useful in this case. I prefer the last approach.

  • @kiattisakphanphu3823
    @kiattisakphanphu3823 4 ปีที่แล้ว

    perfect course , thank you , i'm from thailand

  • @anoopvasudevan
    @anoopvasudevan 4 ปีที่แล้ว

    Super clear explanation!

  • @zahoorhussain196
    @zahoorhussain196 3 ปีที่แล้ว

    I am going to watch all the videos just because the way you explained

  • @kavyashribj
    @kavyashribj 5 ปีที่แล้ว +4

    Thanks for all the effort Vishwas! I have been following all your tutorials. They are simple and straightforward. Would like to know if you could help creating a video about basic idea behind Redux/Flux. All the other tutorials out there are really confusing :(

  • @pavelbukhteev9062
    @pavelbukhteev9062 4 ปีที่แล้ว

    Thank you very much! This course it really useful. I have a question: if I want to change the message from state to state by clicking, what should I do?

  • @prateek4524
    @prateek4524 3 ปีที่แล้ว +1

    you're a savior. Thankyou so much 😊😊🔥🔥

  • @zoomworld767
    @zoomworld767 4 ปีที่แล้ว

    thank you so much for your classes, you are the best teacher
    please upload javascript classes

  • @shivanipanchal8744
    @shivanipanchal8744 4 ปีที่แล้ว

    I like your all videos. Thanku for making videos on React

  • @haciendadad
    @haciendadad 2 ปีที่แล้ว

    Excellent explanation!

  • @sorathavithey890
    @sorathavithey890 4 ปีที่แล้ว +1

    I really love your video brother.

  • @zackstam
    @zackstam 2 ปีที่แล้ว +1

    great tutorial, very helpfull, thank you

  • @md.rakibuddinrana3765
    @md.rakibuddinrana3765 ปีที่แล้ว

    thanks for the superb tutorial😍

  • @nareshkumar-ug5sw
    @nareshkumar-ug5sw 2 ปีที่แล้ว

    Excellent explanation

  • @codedrive7910
    @codedrive7910 3 ปีที่แล้ว

    thanks a lot for
    clearing my doubt

  • @lathagm666
    @lathagm666 8 หลายเดือนก่อน

    completed video 14. Thank You : -)

  • @prateeksaha6287
    @prateeksaha6287 3 ปีที่แล้ว

    i liked ur explanation , thanx a lot man

  • @vaibsify
    @vaibsify 2 ปีที่แล้ว

    awesome explanation 🙏

  • @nesuburak
    @nesuburak 4 ปีที่แล้ว

    Thank you teacher i like this video is very clear

  • @ellsonmds5310
    @ellsonmds5310 4 ปีที่แล้ว +1

    great tutorial, thnx!

  • @valikonen
    @valikonen 4 ปีที่แล้ว +1

    Just PERFECT!

  • @bnsexpress5171
    @bnsexpress5171 3 ปีที่แล้ว

    excellent teaching

  • @visweswarbk7611
    @visweswarbk7611 2 ปีที่แล้ว +1

    Hi - Great presentation Gopinath ! I have a question - How come the "this.state " work in video 11 when we updated the count using setState ? Thanks

  • @akash4517
    @akash4517 4 ปีที่แล้ว

    isn't this video is same as setState method video that you taught earlier .except you taught few other methods to bind.
    great work man. thanks

  • @thedoubtfulhuman
    @thedoubtfulhuman ปีที่แล้ว

    amazing content!!

  • @FoodYogawithRajeesha
    @FoodYogawithRajeesha 2 ปีที่แล้ว

    Very good tutorials

  • @prasobhvc2706
    @prasobhvc2706 2 ปีที่แล้ว

    This is an amazing tutorial

  • @sou123456100
    @sou123456100 ปีที่แล้ว

    This is really very helpfull tutorial

  • @that_marathi_guy
    @that_marathi_guy 4 ปีที่แล้ว

    HI Vishwas,
    So far i was able to follow you in tutorial. In this Video , i have dpubt as, we have used button event to change message and increment value in previous tutorials . How that function invocation different in here from Event calling?

  • @ramsinassyrian7904
    @ramsinassyrian7904 3 ปีที่แล้ว +1

    You are legend man

  • @mjdtoto615
    @mjdtoto615 4 ปีที่แล้ว +8

    In regular functions the this keyword represented the object that called the function, which could be the window, the document, a button or whatever.
    With arrow functions the this keyword always represents the object that defined the arrow function. This is from W3School.

  • @cesarsantana1097
    @cesarsantana1097 3 ปีที่แล้ว +1

    Thank you a lot!

  • @anasalhariri5474
    @anasalhariri5474 2 ปีที่แล้ว

    Thank you so much!

  • @nikolavladimirov1254
    @nikolavladimirov1254 3 ปีที่แล้ว +1

    Thanks man!!!

  • @petruconiuc4618
    @petruconiuc4618 4 ปีที่แล้ว

    how the class properties method (a.k.a the fourth way) works in prodaction now?

  • @segunolamide1989
    @segunolamide1989 10 หลายเดือนก่อน

    Short course but on point.

  • @Aditya.Santra
    @Aditya.Santra 2 ปีที่แล้ว

    Amazing Video

  • @aravindchintha8300
    @aravindchintha8300 ปีที่แล้ว

    i love u so much bro, thanks very much

  • @anoopvasudevan
    @anoopvasudevan 4 ปีที่แล้ว

    Reg the 3rd approach - binding in the constructor, what if the clickHandler is to accept some arguments ? we still have to do binding in the render() method ? like this.clickHandler.bind(null, 'arg');
    if yes, would that cause any performance issues ?

  • @elchino7672
    @elchino7672 3 ปีที่แล้ว

    Super tutorial

  • @ginnyweasley2291
    @ginnyweasley2291 4 ปีที่แล้ว

    8:45 What if I need to pass parameter to the handler function in the third approach?

  • @thekidwithadream
    @thekidwithadream 2 ปีที่แล้ว +3

    I don't get it like haven't we already used onClick event listener in the previous video where we made a counter

  • @ignand
    @ignand 4 ปีที่แล้ว +1

    thank you!

  • @utkarshagrawal3640
    @utkarshagrawal3640 3 ปีที่แล้ว

    To tackle it either we can bind or use an arrow func!

  • @ajaybatham3622
    @ajaybatham3622 4 ปีที่แล้ว

    Thankyou so much....

  • @rahulnag9582
    @rahulnag9582 5 ปีที่แล้ว

    why you are using the () with clickHandler when you are using the arrow function.
    someone please explain....
    thanks in advance

  • @namanjindal3089
    @namanjindal3089 ปีที่แล้ว +2

    The main thing in here was to related the react architecture of components with this, which you have skipped over. That's the main explanation every other thing is pretty common with every tutorial

  • @Wolverine_261
    @Wolverine_261 11 วันที่ผ่านมา +1

    Why does writing arrow function within class and passing it as event handler, makes it run infinite times??

  • @basavareddy
    @basavareddy 2 ปีที่แล้ว

    great video

  • @AxxionMarketPlace-iu6ri
    @AxxionMarketPlace-iu6ri ปีที่แล้ว

    Thank you