3 ms·
If you used this with Backbone, could you throw Backbone's entire View object away and use this instead?
by rubiquity 13y ago
If you used this with Backbone, could you throw Backbone's entire View object away and use this instead?
- ssorallen 13y agoYes, that's the approach I took in our Marathon project (https://github.com/mesosphere/marathon/tree/master/src/main/resources/assets https://github.com/mesosphere/marathon/tree/master/src/main/...). The view is React, the models are Backbone, and I intend to use Backbone's Router as well. Backbone.View is never used.
- jashkenas 13y agoYes, and that's a great use case for it. But you can also use your existing Backbone Views (if they have some nice, say, formatting or data-munging-for-display logic in them) and simply replace your render function with React. The next step you can take is replacing your HTML templates with React's JSX templates, if you'd like...
- rubiquity 13y agoThanks for replying and for your work on CoffeeScript and Backbone. I might give this a try as I love Backbone's Model layer. I think I like the second approach you suggested better. That might almost turn the Backbone.Views into ViewModels, right? I'm still up in the air on how I feel about the whole JSX thing but I'm willing to give it a try.
- SkyMarshal 13y agoFwiw JSX is totally unnecessary, and more verbose anyway. Using React without JSX feels almost like using HAML or something for your HTML.
- jbeja 13y agoReact meant to replace the V in any MV* client frameworks, so yeah you can use it instead
- CGamesPlay 13y agoThat's the typical approach, since React supports composition much more cleanly than Backbone Views do. You can use some mixin like this to handle event listening and updates: https://github.com/CGamesPlay/resistance/blob/master/public/BackboneMixin.js https://github.com/CGamesPlay/resistance/blob/master/public/...