react-collection-helpers
Version:
React Collection Helpers Component
32 lines (22 loc) • 1.18 kB
JavaScript
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; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import React, { PropTypes } from 'react';
import { DISPLAY_NAME_PREFIX } from '../../constants';
import BaseCollectionHelper from '../BaseCollectionHelper';
var First = function First(_ref) {
var collection = _ref.collection,
num = _ref.num,
baseProps = _objectWithoutProperties(_ref, ['collection', 'num']);
return React.createElement(BaseCollectionHelper, _extends({
collection: collection.slice(0, num)
}, baseProps));
};
First.displayName = DISPLAY_NAME_PREFIX + 'First';
process.env.NODE_ENV !== "production" ? First.propTypes = {
collection: PropTypes.array,
num: PropTypes.number.isRequired
} : void 0;
First.defaultProps = {
num: 1
};
export default First;