Skip to content

Instantly share code, notes, and snippets.

View tutuca's full-sized avatar

Matías Iturburu tutuca

View GitHub Profile
@tutuca
tutuca / BackboneMixin.js
Last active August 29, 2015 14:27
A mixin for ReactJS that looks for `this.props.collection` or `this.props.model` listens for all Backbone events to update the React Component.
define([
], function() {
return {
componentDidMount: function() {
this._boundForceUpdate = this.forceUpdate.bind(this, null);
this.getBackboneObject().on("all", this._boundForceUpdate, this);
},
componentWillUnmount: function() {
this.getBackboneObject().off("all", this._boundForceUpdate);
},