import React, { Component } from 'react'; import { AppNotification } from 'app/types'; interface Props { appNotification: AppNotification; onClearNotification: (id) => void; } export default class AppNotificationItem extends Component { shouldComponentUpdate(nextProps) { return this.props.appNotification.id !== nextProps.appNotification.id; } componentDidMount() { const { appNotification, onClearNotification } = this.props; setTimeout(() => { onClearNotification(appNotification.id); }, appNotification.timeout); } render() { const { appNotification, onClearNotification } = this.props; return (
{appNotification.title}
{appNotification.text}
); } }