stampit-org / react-stamp

Composables for React.
370 stars 10 forks source link

Autobind of methods? #38

Closed danielkcz closed 8 years ago

danielkcz commented 8 years ago

It's something that ES6 classes kinda suffer from that all methods you want to pass as a callback has to be manually bound to this. It seems to me that stamps kinda suffer same thing compared to React.createClass that is doing autobind.

So I am wondering how to approach this in here. Manual bind in initializer or directly in callback seems just awkward to me. However full autobind might have some unwanted effects too with mixing various behavior to the stamp, some of those methods might want to keep their original context.

troutowicz commented 8 years ago

Take a look at https://github.com/stampit-org/react-stamp/issues/33. Stamps aren't "suffering", their behaviour is by design.

danielkcz commented 8 years ago

Well I agree that for regular stamps it's good design, but for react stamps it's almost necessity regarding to its performance mentioned in linked issue. I would say that almost best approach would be using decorators, but those are still not ready, so guess initializer it is...thanks.