Hello!
Here, y'all recommend an approach for integrating Backbone models and collections with React and include a code snippet for doing so.
Luckily, this functionality has been achieved using a HoC (like the snippet recommends) in a simple, tested library created by MongoDB called connect-backbone-to-react. We and they (and probably others) have been using the library in production with great success (in our case, for over 6 months).
Recommending connect-backbone-to-react would help devs and projects new to React get up-and-running with React+Backbone quickly and easily. Rather than building their own integration library, they could simply use one that already exists. Also, by centralizing on a solution, the community could collaborate to make the migration from Backbone to React easier and safer for everyone.
connect-backbone-to-react additionally offers a Redux-like provider in BackboneProvider, that many folks may find useful.
Happy to submit a PR to update the docs :). Wanted to check in to get y'all's thoughts first.
cc @gaearon , since you reviewed & merged the original PR that added these docs.
Seems like it's fairly new, maybe it's better to wait until it gets a bit more adoption?
We've use it in production for a year and have made several long-tail bugfixes. It's been well battle tested from our end.
How does it compare to more popular alternatives?
@gaearon :
We considered a few other projects that happened to have more GitHub stars but found connect-backbone-to-react to be the clear winner.
backbone-react-component and react-backbone are both mixins, which we found unappealing. react.backbone's usage is primarily based on a mixin but also "plugs in" by modifying React globally, which we found even less appealing.
connect-backbone-to-react, on the other hand, uses a HoC and, as mentioned, also offers a Redux-like BackboneProvider. MongoDB actively maintains the project and is very responsive to feedback and changes.
While those other projects have more GitHub stars, only two are actually used more, and by a relatively insignificant margin: connect-backbone-to-react vs. backbone-react-component, react-backbone, and react.backbone.
馃憢 Hi there, original author of connect-backbone-to-react here! Really excited to see this issue open, thank you @spencer-brown!
Since writing this library we've been using it in production at MongoDB (for our Atlas product) since April of last year without any issues. It's been a great addition to our toolchain, allowing us to gradually migrate our (very large) codebase from Backbone/Marionette to React. Having connect-backbone-to-react be the glue between these two frameworks has been great as it lets us leverage our existing BB Models while still allowing our React components to be oblivious to their existence.
It was written before the doc additions but mostly codifies many of the recommendations of those doc changes. Due to it being a self contained library we're also able to test it in isolation, doing our best to ensure that this glue between two frameworks doesn't leak or cause any un-expected errors. (The pain of glueing frameworks and having that glue be brittle is a pain that I never want to re-live.)
I'm not sure how many developers are doing gradual migrations from Backbone to React so that may explain the (lack of) popularity.
In any event, I would love to see it included in the docs as I do think it is beneficial to other developers out there who are in a similar situation as @spencer-brown and I.
thoughts @gaearon ?
bump @gaearon :)
Most helpful comment
馃憢 Hi there, original author of
connect-backbone-to-reacthere! Really excited to see this issue open, thank you @spencer-brown!Since writing this library we've been using it in production at MongoDB (for our Atlas product) since April of last year without any issues. It's been a great addition to our toolchain, allowing us to gradually migrate our (very large) codebase from Backbone/Marionette to React. Having
connect-backbone-to-reactbe the glue between these two frameworks has been great as it lets us leverage our existing BB Models while still allowing our React components to be oblivious to their existence.It was written before the doc additions but mostly codifies many of the recommendations of those doc changes. Due to it being a self contained library we're also able to test it in isolation, doing our best to ensure that this glue between two frameworks doesn't leak or cause any un-expected errors. (The pain of glueing frameworks and having that glue be brittle is a pain that I never want to re-live.)
I'm not sure how many developers are doing gradual migrations from Backbone to React so that may explain the (lack of) popularity.
In any event, I would love to see it included in the docs as I do think it is beneficial to other developers out there who are in a similar situation as @spencer-brown and I.