Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZijun Liao
13,409 PointshandleRemovePlayer binding
It seems that handleRemovePlayer is bind to App by arrow function at the beginning. And later on it is bind to Player inside onClick method, anyone explain about that and what is the this keyword refer to now?
1 Answer
Ashiwn Ashok
6,774 PointsHere the "handleRemovePlayer" is bind to the "App". However, the component "Player" is able to use this function because the "App" component is passing a reference to the same function via props, which is then is being used by the player component.
Coming to what "this" stands for, it depends on the component you are referring to. For example, the "this" used inside "App" component refers to the "App" React component class itself. Similarly, the "this" inside the "Counter" component refers to the same "Counter" component itself.