AnimateGroup.js 1022 B

1234567891011121314151617181920212223242526272829303132
  1. import React, { Children } from 'react';
  2. import { TransitionGroup } from 'react-transition-group';
  3. import PropTypes from 'prop-types';
  4. import AnimateGroupChild from './AnimateGroupChild';
  5. function AnimateGroup(props) {
  6. var component = props.component,
  7. children = props.children,
  8. appear = props.appear,
  9. enter = props.enter,
  10. leave = props.leave;
  11. return /*#__PURE__*/React.createElement(TransitionGroup, {
  12. component: component
  13. }, Children.map(children, function (child, index) {
  14. return /*#__PURE__*/React.createElement(AnimateGroupChild, {
  15. appearOptions: appear,
  16. enterOptions: enter,
  17. leaveOptions: leave,
  18. key: "child-".concat(index) // eslint-disable-line
  19. }, child);
  20. }));
  21. }
  22. AnimateGroup.propTypes = {
  23. appear: PropTypes.object,
  24. enter: PropTypes.object,
  25. leave: PropTypes.object,
  26. children: PropTypes.oneOfType([PropTypes.array, PropTypes.element]),
  27. component: PropTypes.any
  28. };
  29. AnimateGroup.defaultProps = {
  30. component: 'span'
  31. };
  32. export default AnimateGroup;