54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
|
import _createClass from 'babel-runtime/helpers/createClass';
|
|
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
|
import _inherits from 'babel-runtime/helpers/inherits';
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
var SaveRef = function (_React$Component) {
|
|
_inherits(SaveRef, _React$Component);
|
|
|
|
function SaveRef() {
|
|
var _ref;
|
|
|
|
var _temp, _this, _ret;
|
|
|
|
_classCallCheck(this, SaveRef);
|
|
|
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = SaveRef.__proto__ || Object.getPrototypeOf(SaveRef)).call.apply(_ref, [this].concat(args))), _this), _this.getRef = function (name) {
|
|
return _this[name];
|
|
}, _this.saveRef = function (name) {
|
|
return function (node) {
|
|
if (node) {
|
|
_this[name] = node;
|
|
}
|
|
};
|
|
}, _temp), _possibleConstructorReturn(_this, _ret);
|
|
}
|
|
|
|
_createClass(SaveRef, [{
|
|
key: 'render',
|
|
value: function render() {
|
|
return this.props.children(this.saveRef, this.getRef);
|
|
}
|
|
}]);
|
|
|
|
return SaveRef;
|
|
}(React.Component);
|
|
|
|
export default SaveRef;
|
|
|
|
|
|
SaveRef.propTypes = {
|
|
children: PropTypes.func
|
|
};
|
|
|
|
SaveRef.defaultProps = {
|
|
children: function children() {
|
|
return null;
|
|
}
|
|
}; |