Mixin de roteador simples para React

var RouterMixin = {
respondTo
: function(routes, root, pushState) {
var self = this;

if (!router) {
router
= new Backbone.Router();
}

for (var route in routes) {
var name = 'route' + routeId++;
router
.route(route, name, routes[route].bind(self));
}

if (!started) {
pushState
= !!pushState;
Backbone.history.start({ root: root || '/', pushState: pushState });
started
= true;
}
}
};

Exemplo:

React.createClass({
mixin
: [Router],
componentDidMount
: function() {
this.respondTo({
'': this.fetchData,
'features/:id': this.fetchFeature
});
},
fetchData
: function() {
...
},
fetchFeature
: function(id) {
...
}
});

Créditos:

https://gist.github.com/darthapo/7165970