Тёмный

ReactJS Tutorial - 14 - Binding Event Handlers 

Codevolution
Подписаться 670 тыс.
Просмотров 579 тыс.
50% 1

📘 Courses - learn.codevolu...
💖 Support UPI - support.codevo...
💖 Support PayPal - www.paypal.me/...
💾 Github - github.com/gop...
📱 Follow Codevolution
Twitter - / codevolutionweb
Facebook - / codevolutionweb
📫 Business - codevolution.business@gmail.com
In this video, lets learn how to bind event handlers in React components.

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

 

6 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 280   
@isaacdruin
@isaacdruin 4 года назад
"so in this video, I will go over all of them" What a legend.
@satisfyingindustrialequipment
@satisfyingindustrialequipment 5 лет назад
I rarely comment on RU-vid 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 года назад
True! Clear and concise! Very helpful.
@zeeu
@zeeu 2 года назад
I hope you already landed your dream job
@dylanoh3425
@dylanoh3425 4 года назад
This channel is definitely underrated. It deserves more attentions!! Great work man.
@vinitraut1425
@vinitraut1425 5 лет назад
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 года назад
Yes. This is the actual reason it gives undefined.
@meghalbisht6768
@meghalbisht6768 4 года назад
please elaborate a little
@akashgupta1353
@akashgupta1353 4 года назад
hey please elaborate more
@jatintayal4358
@jatintayal4358 4 года назад
arrow functions don't create their own context so there it worked without binding.
@pradeepsaravanan4348
@pradeepsaravanan4348 4 года назад
@@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 .
@toannew
@toannew 3 года назад
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
@Daniel-nb3kk
@Daniel-nb3kk 4 года назад
You explain concepts and ideas so well a mere child will understand you. Great job!
@nishantagrawal6244
@nishantagrawal6244 3 года назад
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.
@TheInfamousAlpha
@TheInfamousAlpha 5 лет назад
(this) was great explanation
@kran399
@kran399 4 года назад
haaha yes (this) was
@moderncloth682
@moderncloth682 4 года назад
this.setState({ comment: 'Haha, coding joke' })
@Nikhilsharma-dp9tw
@Nikhilsharma-dp9tw 3 года назад
@@moderncloth682 undefined
@taharasheed2096
@taharasheed2096 3 года назад
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 )
@edwinvarghese
@edwinvarghese 3 года назад
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.
@GeryTeague
@GeryTeague 9 месяцев назад
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.
@vishnugajulapalli5305
@vishnugajulapalli5305 3 года назад
1. Binding in render 2. Arrow function in render 3. Binding in the class constructor 4. Class property as arrow function
@MrBelleblaas
@MrBelleblaas 3 года назад
Absolutely exellent. My threshold to continue with React has been set from now. Thank you very much.
@PragnaPresence
@PragnaPresence 3 года назад
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.
@souvikkar5515
@souvikkar5515 3 года назад
Bruh! the best react tutorial on the whole YT. Small yet detailed videos.
@ANOTHERWOOK
@ANOTHERWOOK 3 года назад
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!
@simbarashemaunga5575
@simbarashemaunga5575 Год назад
It's really great how you give examples for both class based and functional components.
@KelleyKouture
@KelleyKouture 4 года назад
FinallFinally!!!! A video that actually helped me and explained it so well! Thank you so much!!
@maghani.official
@maghani.official 4 года назад
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
@VOLTDOGmusic
@VOLTDOGmusic 5 лет назад
One of the best teachers on RU-vid, thanks bruddah!
@mjdtoto615
@mjdtoto615 4 года назад
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.
@thekidwithadream
@thekidwithadream 2 года назад
I don't get it like haven't we already used onClick event listener in the previous video where we made a counter
@kumarp5632
@kumarp5632 4 года назад
You made ReactsJs very simple and clean to understand.. Great Work and Kudos
@xavier.antony
@xavier.antony Год назад
You guys are professional teachers. Awesome..
@batulmajid
@batulmajid 4 года назад
After long research, i finally find something which satisfies me. Thanks Man!
@Paparoo24
@Paparoo24 3 года назад
Arrow functions are very useful in this case. I prefer the last approach.
@ShreyaskarART
@ShreyaskarART Год назад
This course so far is the most intuitive one, I'm loving it !
@AnotherLeetcode
@AnotherLeetcode 4 года назад
This is the first video I've seen that effectively explains 'bind(this)' well. Thank you!!
@sanjeetsahni4998
@sanjeetsahni4998 5 лет назад
For beginners this video are must watch.. I got lot of confusion but after watching these videos everything is clear now..
@priyankas7136
@priyankas7136 4 года назад
Yes. This tutorial is amazing. As a beginner I am getting to learn alot. Very good work Mr Vishwas
@RegularExpression1
@RegularExpression1 5 лет назад
Excellent brief tutorial that covers topic well in a few minutes time. Thanks.
@tannerbarcelos6880
@tannerbarcelos6880 4 года назад
Best explanation of bind() ! As a Java and C++ guy in school, it was easy to understand this. OOP for the win
@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.
@pipertripp
@pipertripp 5 лет назад
Also, Vishwas, this is an excellent series. Well done mate.
@aqibsaeed3229
@aqibsaeed3229 2 года назад
Just Excellent and Simplest way of explaining all cases with sequence and basic example. Keep up great work.
@yaw199
@yaw199 3 года назад
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!!!
@mohdsalim3790
@mohdsalim3790 3 года назад
sir i like your way of teaching...you explain every concept in a easy way
@johnm7571
@johnm7571 Год назад
in 2023 ur videos are the best from all other tutors
@azar1608
@azar1608 4 года назад
What a great explaination man, I understood the basic of react from your course, thanks for sharing
@avinashsuntosh8620
@avinashsuntosh8620 4 года назад
Vishwas, you rock man! Thanks so much for these beautiful tutorials. Much appreciated.
@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.
@devGamersCoders
@devGamersCoders 2 года назад
"this" is undefined because this works perfectly if the function is in a method or have object as a wrapper but here we are wrapping inside a class not object that's why this is undefined so binding it is a solution inside that constructor else use arrow function
@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.
@abdokhalaf6188
@abdokhalaf6188 3 года назад
Generally speaking in JavaScript, you can change the context of the "this" keyword of any function,not including the arrow function for sure, using the apply, call or bind methods by passing the object you want the "this" keyword to refer to as the first parameter of these methods But here we can only use the bind method since both apply and call methods will call the function directly without the event a.k.a the click event, making your application enters a sort of infinity function calls
@kavyashribj
@kavyashribj 5 лет назад
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 :(
@zahoorhussain196
@zahoorhussain196 3 года назад
I am going to watch all the videos just because the way you explained
@nakimapi
@nakimapi 4 года назад
such a clean way of teaching!
@alexsampaio9198
@alexsampaio9198 3 года назад
You're a legend, man. Keep it up.
@zoomworld767
@zoomworld767 4 года назад
thank you so much for your classes, you are the best teacher please upload javascript classes
@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
@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
@apurvsawant5703
@apurvsawant5703 4 года назад
Thank you for providing this content. Great Work.
@shvideo1
@shvideo1 5 лет назад
Excellent comprehensive and clear instruction. Very helpful. Thank you.
@tungngo2445
@tungngo2445 5 лет назад
Your video helps me tremendously. Thank you so much. You are a great teacher
@Shahidulidseacademy
@Shahidulidseacademy 3 года назад
This tutorial is very useful for me, Thank you Codevolution !
@zackstam
@zackstam 2 года назад
great tutorial, very helpfull, thank you
@prateek4524
@prateek4524 4 года назад
you're a savior. Thankyou so much 😊😊🔥🔥
@maiaklimenko6614
@maiaklimenko6614 2 года назад
Thank you for the amazing and simple explanation!
@АлександрЖарков-у9ш
I think the first solution will be better if you place .bind at the constructor like this: constructor(props) { super(props); this.state = { message: 'Hello', }; this.clicker = this.clicker.bind(this); } The benefit is that it woun't rerender every time the button has clicked. Update: my bad, you've already told it, but i wrote this comment when i watched only half of the video
@AZnuclear
@AZnuclear 4 года назад
Congratulations my friend, that was a very good tutorial
@divyapawar6269
@divyapawar6269 2 года назад
The tutorial are good but most of them are based on classes. And now classes are out of function....
@juliocesarbenavente9590
@juliocesarbenavente9590 4 года назад
I understood why 'this' keyword doesn't work, I don't know if you explained it but I don't get why 'bind(this)' works. Thanks for the work!
@art_and_craft868
@art_and_craft868 Год назад
Me too
@utkarshagrawal3640
@utkarshagrawal3640 3 года назад
To tackle it either we can bind or use an arrow func!
@shivanipanchal8744
@shivanipanchal8744 4 года назад
I like your all videos. Thanku for making videos on React
@lintstudios3072
@lintstudios3072 2 года назад
Great video! Helped me so much! keep up the great work.
@faruzzy
@faruzzy 5 лет назад
This is gold!! Thanks!
@anoopvasudevan
@anoopvasudevan 4 года назад
Super clear explanation!
@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?
@sorathavithey890
@sorathavithey890 4 года назад
I really love your video brother.
@visweswarbk7611
@visweswarbk7611 2 года назад
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
@nareshkumar-ug5sw
@nareshkumar-ug5sw 2 года назад
Excellent explanation
@lathagm666
@lathagm666 11 месяцев назад
completed video 14. Thank You : -)
@sm-fj4yt
@sm-fj4yt 5 месяцев назад
As fer I understand in 3:54 , under the button the value of this is buttonObject. So literally {this.clickHandler} is same as {buttonObject.clickHandler}. Bt the outer clickHandler where clickHandler method is definedn is in scope of EventBind object. So this value is EventBind outside. So we can say this.state is same as EventBind.state. which is not accessible to the event handler in button. Bt for arrow function the this value is same as enclosed lexical context means for arrow function this value becoms EventBind object. So this.state is accessible if we use arrow function. thats wthe reason for arrow function we dont get undefined also... Pls correct me if wrong. It will be helpful for me to clear the concepts😊
@kiattisakphanphu3823
@kiattisakphanphu3823 4 года назад
perfect course , thank you , i'm from thailand
@haciendadad
@haciendadad 2 года назад
Excellent explanation!
@tomasruzicka9835
@tomasruzicka9835 3 года назад
If i wasn't familiar with JS this keyword and prototyping I'd be confused as swarming forest bee.
@bnsexpress5171
@bnsexpress5171 4 года назад
excellent teaching
@medhapatil1372
@medhapatil1372 5 лет назад
Thank you so much! Great Tutorial.
@ramsinassyrian7904
@ramsinassyrian7904 3 года назад
You are legend man
@prateeksaha6287
@prateeksaha6287 3 года назад
i liked ur explanation , thanx a lot man
@codedrive7910
@codedrive7910 3 года назад
thanks a lot for clearing my doubt
@forkanalam6530
@forkanalam6530 5 лет назад
Your explanation is superb,but on video no 10 about state you did this before by declaring a arrow function in onClick method..
@vaibsify
@vaibsify 2 года назад
awesome explanation 🙏
@ExpertGirl-i5w
@ExpertGirl-i5w Месяц назад
best best best channel in 2024
@segunolamide1989
@segunolamide1989 Год назад
Short course but on point.
@valikonen
@valikonen 4 года назад
Just PERFECT!
@ellsonmds5310
@ellsonmds5310 4 года назад
great tutorial, thnx!
@koustubhmuktibodh4901
@koustubhmuktibodh4901 5 лет назад
Sir your teaching is best than Maxmueler.
@muaazhammad4446
@muaazhammad4446 4 года назад
better*
@cesarsantana1097
@cesarsantana1097 3 года назад
Thank you a lot!
@md.rakibuddinrana3765
@md.rakibuddinrana3765 Год назад
thanks for the superb tutorial😍
@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?
@yogawithRajeesha
@yogawithRajeesha 3 года назад
Very good tutorials
@prasobhvc2706
@prasobhvc2706 2 года назад
This is an amazing tutorial
@Wolverine_261
@Wolverine_261 2 месяца назад
Why does writing arrow function within class and passing it as event handler, makes it run infinite times??
@ignand
@ignand 4 года назад
thank you!
@judewestburner
@judewestburner 3 года назад
Approach number 4 is easily the cleanest
@umamaheshmeka1032
@umamaheshmeka1032 3 года назад
for somebody who is wondering about 'this' here is an example. *if you run this below code, both this value will be pointing to window object* ``` console.log(this) function sample(){ console.log(this) } ``` *if run the same code using strict mode 'this' inside function will be undefined.* ``` 'use strict'; console.log(this) function sample(){ console.log(this) } ``` *because in strict mode global object refers to undefined in place of the window object* *below code will fix the issue* 'use strict'; console.log(this) function sample(){ console.log(this) } var output = sample.bind(this) // *you need to invoke output as bind method returns a function* output()
@lilianaleyva2763
@lilianaleyva2763 3 года назад
Plaese make a Udemy tutorial 🙏🙏
@nesuburak
@nesuburak 4 года назад
Thank you teacher i like this video is very clear
@sou123456100
@sou123456100 Год назад
This is really very helpfull tutorial
Далее
ReactJS Tutorial - 15 - Methods as props
8:45
Просмотров 496 тыс.
ReactJS Tutorial - 16 - Conditional Rendering
11:46
Просмотров 488 тыс.
ReactJS Tutorial - 13 - Event Handling
7:36
Просмотров 664 тыс.
Every React Concept Explained in 12 Minutes
11:53
Просмотров 687 тыс.
5 JavaScript Concepts You HAVE TO KNOW
9:38
Просмотров 1,4 млн
Learn JSON in 10 Minutes
12:00
Просмотров 3,2 млн
ReactJS Tutorial - 20 - Styling and CSS Basics
11:40
Просмотров 511 тыс.
ReactJS Tutorial - 32 - Error Boundary
10:53
Просмотров 267 тыс.
Why Signals Are Better Than React Hooks
16:30
Просмотров 479 тыс.
All The JavaScript You Need To Know For React
28:00
Просмотров 624 тыс.