-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuineaPigsContainer.compiled.js
213 lines (159 loc) · 9.08 KB
/
GuineaPigsContainer.compiled.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
/**
* Uses the react-transform babel plugin
* to rewrite modules so that all react components are
* exported.
*
* This allows us to access those components and test them.
*
* ex:
*
* // component.js
*
* var MyComponent = React.createClass({});
*
* // component-test.js
*
* var components = require('../component.js');
*
* console.log(components.__ReactComponents.MyComponent);
*
*/
module.exports = function createExport(_ref) {
var locals = _ref.locals;
return function (ReactClass, componentId) {
if (!locals[0].exports) {
locals[0].exports = {};
}
if (!locals[0].exports.__ReactComponents) {
locals[0].exports.__ReactComponents = [];
}
locals[0].exports.__ReactComponents.push(ReactClass);
return ReactClass;
};
};
},{}],2:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GuineaPigs = undefined;
var _react2 = require('react');
var _react3 = _interopRequireDefault(_react2);
var _reactTransformComponentExports = require('/home/ccuser/.babelscripts/react-transform-component-exports');
var _reactTransformComponentExports2 = _interopRequireDefault(_reactTransformComponentExports);
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _components = {
GuineaPigs: {
displayName: 'GuineaPigs'
}
};
var _homeCcuserBabelscriptsReactTransformComponentExports2 = (0, _reactTransformComponentExports2.default)({
filename: '/home/ccuser/workspace/react-102-container-presentational-components-container-presentational-components-apply-2/components/GuineaPigs.js',
components: _components,
locals: [module],
imports: [_react3.default]
});
function _wrapComponent(id) {
return function (Component) {
return _homeCcuserBabelscriptsReactTransformComponentExports2(Component, id);
};
}
var GuineaPigs = exports.GuineaPigs = _wrapComponent('GuineaPigs')(function (_React$Component) {
_inherits(GuineaPigs, _React$Component);
function GuineaPigs() {
_classCallCheck(this, GuineaPigs);
return _possibleConstructorReturn(this, (GuineaPigs.__proto__ || Object.getPrototypeOf(GuineaPigs)).apply(this, arguments));
}
_createClass(GuineaPigs, [{
key: 'render',
value: function render() {
var src = this.props.src;
return _react3.default.createElement(
'div',
null,
_react3.default.createElement(
'h1',
null,
'Cute Guinea Pigs'
),
_react3.default.createElement('img', { src: src })
);
}
}]);
return GuineaPigs;
}(_react3.default.Component));
},{"/home/ccuser/.babelscripts/react-transform-component-exports":1,"react":undefined}],3:[function(require,module,exports){
'use strict';
var _react2 = require('react');
var _react3 = _interopRequireDefault(_react2);
var _reactTransformComponentExports = require('/home/ccuser/.babelscripts/react-transform-component-exports');
var _reactTransformComponentExports2 = _interopRequireDefault(_reactTransformComponentExports);
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _reactDom = require('react-dom');
var _reactDom2 = _interopRequireDefault(_reactDom);
var _GuineaPigs = require('../components/GuineaPigs');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _components = {
GuineaPigsContainer: {
displayName: 'GuineaPigsContainer'
}
};
var _homeCcuserBabelscriptsReactTransformComponentExports2 = (0, _reactTransformComponentExports2.default)({
filename: '/home/ccuser/workspace/react-102-container-presentational-components-container-presentational-components-apply-2/containers/GuineaPigsContainer.js',
components: _components,
locals: [module],
imports: [_react3.default]
});
function _wrapComponent(id) {
return function (Component) {
return _homeCcuserBabelscriptsReactTransformComponentExports2(Component, id);
};
}
var GUINEAPATHS = ['https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-guineapig-1.jpg', 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-guineapig-2.jpg', 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-guineapig-3.jpg', 'https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-guineapig-4.jpg'];
var GuineaPigsContainer = _wrapComponent('GuineaPigsContainer')(function (_React$Component) {
_inherits(GuineaPigsContainer, _React$Component);
function GuineaPigsContainer(props) {
_classCallCheck(this, GuineaPigsContainer);
var _this = _possibleConstructorReturn(this, (GuineaPigsContainer.__proto__ || Object.getPrototypeOf(GuineaPigsContainer)).call(this, props));
_this.state = { currentGP: 0 };
_this.interval = null;
_this.nextGP = _this.nextGP.bind(_this);
return _this;
}
_createClass(GuineaPigsContainer, [{
key: 'nextGP',
value: function nextGP() {
var current = this.state.currentGP;
var next = ++current % GUINEAPATHS.length;
this.setState({ currentGP: next });
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
this.interval = setInterval(this.nextGP, 5000);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
clearInterval(this.interval);
}
}, {
key: 'render',
value: function render() {
var src = GUINEAPATHS[this.state.currentGP];
return _react3.default.createElement(_GuineaPigs.GuineaPigs, { src: src });
}
}]);
return GuineaPigsContainer;
}(_react3.default.Component));
_reactDom2.default.render(_react3.default.createElement(GuineaPigsContainer, null), document.getElementById('app'));
},{"../components/GuineaPigs":2,"/home/ccuser/.babelscripts/react-transform-component-exports":1,"react":undefined,"react-dom":undefined}]},{},[3]);