Why and how to bind methods in your React component classes?

added by bpwndaddy
7/24/2015 12:47:56 PM

389 Views

React v0.13 introduced a major change in how you can define your component classes. What was a React-bound class system was slimmed down to a level where the pure JavaScript classes can be used. It has many benefits - your component classes are not ‘magical’ anymore, you can take advantage of the common JavaScript idioms and so on. This change emphasized that React is JavaScript - and React authors don’t want to escape this truth. That change encourages you to use language features, not custom solutions to create your React code. For people coming from different background than JavaScript / Node.js using some language features can be confusing. One of those confusing features is function context binding in JavaScript. In this blogpost I want to explain how and why you need to do it.


0 comments