diff --git a/src/Notifications.js b/src/Notifications.js index eb77d3d..894a553 100644 --- a/src/Notifications.js +++ b/src/Notifications.js @@ -4,59 +4,51 @@ import { CSSTransitionGroup } from 'react-transition-group'; import classnames from 'classnames'; import Notification from './Notification'; -class Notifications extends React.Component { - static propTypes = { - notifications: PropTypes.array.isRequired, - onRequestHide: PropTypes.func, - enterTimeout: PropTypes.number, - leaveTimeout: PropTypes.number +const Notifications = ({ + notifications = [], + onRequestHide = () => { }, + enterTimeout = 400, + leaveTimeout = 400 +}) => { + const handleRequestHide = notification => () => { + if (onRequestHide) onRequestHide(notification); }; - static defaultProps = { - notifications: [], - onRequestHide: () => { - }, - enterTimeout: 400, - leaveTimeout: 400 - }; - - handleRequestHide = notification => () => { - const { onRequestHide } = this.props; - if (onRequestHide) { - onRequestHide(notification); - } - }; + const className = classnames('notification-container', { + 'notification-container-empty': notifications.length === 0 + }); - render() { - const { notifications, enterTimeout, leaveTimeout } = this.props; - const className = classnames('notification-container', { - 'notification-container-empty': notifications.length === 0 - }); - return ( -
- - {notifications.map((notification) => { - const key = notification.id || new Date().getTime(); - return ( - - ); - })} - -
- ); - } + return ( +
+ + {notifications.map((notification) => { + const key = notification.id || new Date().getTime(); + return ( + + ); + })} + +
+ ); } +Notifications.propTypes = { + notifications: PropTypes.array.isRequired, + onRequestHide: PropTypes.func, + enterTimeout: PropTypes.number, + leaveTimeout: PropTypes.number +}; + export default Notifications;