Why react uses bind this and arrow function in a component

September 16, 2017


The ES2015 specification introduces thearrow function syntaxfor writing function expressions. As well as being terser than regular function expressions, they can also have implicit return and most importantly, they always use the value ofthisfrom the enclosing scope.

Bind this

React allows you to define arbitrary methods on your component classes and these methods are automatically bound with the correct context forthiswhen you create your components withReact.createClass. This allows you move your callback code out onto your component.

Tagged withreact, javascript

Questions, Comments, Suggestions? Open an Issue