Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
if (typeof define === 'function' && define.amd) {
define(['react', 'backbone', 'underscore'], factory);
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = factory(require('react'), require('backbone'), require('underscore'));
react = require('react-native'); // React Native
isReactNative = true;
module.exports = factory(isReactNative, react, require('backbone'), require('underscore'));
} else {
factory(root.React, root.Backbone, root._);
}
}(this, function (React, Backbone, _) {
}(this, function (isReactNative, React, Backbone, _) {
'use strict';
if (!Backbone.React) {
Backbone.React = {};
Expand Down Expand Up @@ -70,11 +72,15 @@
},
// Sets `this.el` and `this.$el` when the component mounts.
componentDidMount: function () {
this.setElement(React.findDOMNode(this));
if (isReactNative === false) {
this.setElement(React.findDOMNode(this));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like if (React.findDOMNode) is better to avoid having to set an extra flag for it (isReactNative)?

},
// Sets `this.el` and `this.$el` when the component updates.
componentDidUpdate: function () {
this.setElement(React.findDOMNode(this));
if (isReactNative === false) {
this.setElement(React.findDOMNode(this));
}
},
// When the component gets the initial state, instance a `Wrapper` to take
// care of models and collections binding with `this.state`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"peerDependencies": {
"backbone": "^1.2.3",
"react": "^0.13.3"
"react-native": ">=0.14.0"
},
"dependencies": {
"underscore": "^1.8.3"
Expand Down