refire-react
Version:
React components and helpers for Refire
58 lines • 2.42 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var PropTypes = require("prop-types");
var React = require("react");
var react_1 = require("react");
var Bind = /** @class */ (function (_super) {
__extends(Bind, _super);
function Bind() {
return _super !== null && _super.apply(this, arguments) || this;
}
Bind.prototype.componentDidMount = function () {
var _a = this.props, array = _a.array, as = _a.as, name = _a.name, path = _a.path, populate = _a.populate, populateWith = _a.populateWith, from = _a.from, query = _a.query;
this.context.syncFirebase.addBinding({
name: as || name,
path: from || path,
populate: populateWith || populate,
query: query,
type: array ? "Array" : "Object"
});
};
Bind.prototype.componenWillUnmount = function () {
this.context.syncFirebase.removeBinding(this.props.as);
};
Bind.prototype.componentWillReceiveProps = function (nextProps, nextContext) {
var array = nextProps.array, as = nextProps.as, name = nextProps.name, path = nextProps.path, populate = nextProps.populate, populateWith = nextProps.populateWith, from = nextProps.from, query = nextProps.query;
nextContext.syncFirebase.updateBinding({
name: as || name,
path: from || path,
populate: populateWith || populate,
query: query,
type: array ? "Array" : "Object"
});
};
Bind.prototype.render = function () {
var children = this.props.children;
if (children) {
return React.createElement("div", null, children);
}
return null;
};
Bind.contextTypes = {
syncFirebase: PropTypes.object.isRequired
};
return Bind;
}(react_1.Component));
exports.Bind = Bind;
exports.default = Bind;
//# sourceMappingURL=Bind.js.map