diff --git a/lib/store_watch_mixin.js b/lib/store_watch_mixin.js index 05dc11b..c5792b5 100644 --- a/lib/store_watch_mixin.js +++ b/lib/store_watch_mixin.js @@ -6,8 +6,14 @@ var StoreWatchMixin = function() { componentDidMount: function() { var flux = this.props.flux || this.context.flux; this.mounted = true; + // No autobinding in ES6 classes - this._setStateFromFlux = this._setStateFromFlux.bind(this); + this._setStateFromFlux = function() { + if(this.mounted) { + this.setState(this.getStateFromFlux()); + } + }.bind(this); + _each(storeNames, function(store) { flux.store(store).on("change", this._setStateFromFlux); }, this); @@ -21,12 +27,6 @@ var StoreWatchMixin = function() { }, this); }, - _setStateFromFlux: function() { - if(this.mounted) { - this.setState(this.getStateFromFlux()); - } - }, - getInitialState: function() { return this.getStateFromFlux(); }