From 25a1e5acae0e0709bff56573e744b034dff61429 Mon Sep 17 00:00:00 2001 From: Alireza Mostafizi Date: Sun, 23 Oct 2016 05:44:29 -0700 Subject: [PATCH] Update handling-events.md (#8057) --- docs/handling-events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/handling-events.md b/docs/handling-events.md index ae70872b4..e1bf9828d 100644 --- a/docs/handling-events.md +++ b/docs/handling-events.md @@ -91,7 +91,7 @@ ReactDOM.render( [Try it on CodePen.](http://codepen.io/gaearon/pen/xEmzGg?editors=0010) -You have to be careful about the meaning of `this` in JSX callbacks. In JavaScript, class methods are not [bound](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind) by default. If you forget to bind `this.toggle` and pass it to `onClick`, `this` will be `undefined` when the function is actually called. +You have to be careful about the meaning of `this` in JSX callbacks. In JavaScript, class methods are not [bound](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind) by default. If you forget to bind `this.handleClick` and pass it to `onClick`, `this` will be `undefined` when the function is actually called. This is not React-specific behavior; it is a part of [how functions work in JavaScript](https://www.smashingmagazine.com/2014/01/understanding-javascript-function-prototype-bind/). Generally, if you refer to a method without `()` after it, such as `onClick={this.handleClick}`, you should bind that method.