I have found several different examples of integrating React (View) with Backbone on the web, but not any to do the same with React Native. I was wondering if this was possible and also if there were any samples to play with.
This (https://github.com/magalhas/backbone-react-component) also seemed a good starting point, but since I don't have any knowledge, I am not sure if it can still be used in React Native.
Thanks.
You'll be able to use some parts of Backbone, yes.
Backbone's views operate on the DOM in the web browser, and since React Native doesn't have that, you'll be unable to use Backbone view as-is.
However, notice that Backbone.React.Component is described as "a mixin that glues Backbone models and collections into React components". Therefore it works as the data layer of your application, supplying data to your view.
This would be useful in theory, but in practice I've just tried it and it doesn't actually work! That said, I did managed to tweak the code of Backbone.React.Component to fix it though, and this demo works:
You will see the value of
foo
from the model shown on screen as "Hello world!". You will need to edit lib/component.js in Backbone.React.Component like this:I made two changes:
React
instead ofreact
findDOMNode
I haven't done any extensive testing but this should get you started. I've also opened an issue to try and get the problem addressed in the main Backbone.React.Component code base.