Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80517 views
1
'use strict';
2
3
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };
4
5
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
6
7
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
8
9
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
10
11
/**
12
* Higher-order component form of connectToStores
13
*/
14
15
var _React = require('react');
16
17
var React = _interopRequire(_React);
18
19
var _instanceMethods$staticProperties = require('./reactComponentMethods');
20
21
var _assign = require('object-assign');
22
23
var assign = _interopRequire(_assign);
24
25
module.exports = function (BaseComponent, stores, stateGetter) {
26
var ConnectedComponent = (function (_React$Component) {
27
var _class = function ConnectedComponent(props, context) {
28
_classCallCheck(this, _class);
29
30
_React$Component.call(this, props, context);
31
32
this.initialize();
33
34
this.state = this.connectToStores(stores, stateGetter);
35
};
36
37
_inherits(_class, _React$Component);
38
39
_class.prototype.render = function render() {
40
return React.createElement(BaseComponent, _extends({}, this.state, this.props));
41
};
42
43
return _class;
44
})(React.Component);
45
46
assign(ConnectedComponent.prototype, _instanceMethods$staticProperties.instanceMethods);
47
48
assign(ConnectedComponent, _instanceMethods$staticProperties.staticProperties);
49
50
return ConnectedComponent;
51
};
52