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!
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 trial
Zijun Liao13,409 Points
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?
Ashiwn Ashok6,774 Points
Here 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.