1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 |
|
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
8 |
|
9 | var _react = require('react');
|
10 |
|
11 | var _react2 = _interopRequireDefault(_react);
|
12 |
|
13 | var _invariant = require('invariant');
|
14 |
|
15 | var _invariant2 = _interopRequireDefault(_invariant);
|
16 |
|
17 | var ContextWrapper = _react2['default'].createClass({
|
18 | displayName: 'ThunderCatsContextWrapper',
|
19 | propTypes: {
|
20 | cat: _react2['default'].PropTypes.object.isRequired,
|
21 | children: _react2['default'].PropTypes.element.isRequired
|
22 | },
|
23 |
|
24 | childContextTypes: {
|
25 | cat: _react2['default'].PropTypes.object.isRequired
|
26 | },
|
27 |
|
28 | getChildContext: function getChildContext() {
|
29 | return {
|
30 | cat: this.props.cat
|
31 | };
|
32 | },
|
33 |
|
34 | render: function render() {
|
35 | return _react.Children.only(this.props.children);
|
36 | }
|
37 | });
|
38 |
|
39 |
|
40 |
|
41 | ContextWrapper.wrap = function wrap(element, cat) {
|
42 | (0, _invariant2['default'])(_react2['default'].isValidElement(element), 'ContextWrapper wrap expects a valid React element');
|
43 |
|
44 | (0, _invariant2['default'])(typeof cat === 'object', 'ContextWrapper expects an instance of Cat');
|
45 |
|
46 | return _react2['default'].createElement(ContextWrapper, { cat: cat }, element);
|
47 | };
|
48 |
|
49 | exports['default'] = ContextWrapper;
|
50 | module.exports = exports['default']; |
\ | No newline at end of file |