import React, { Component } from 'react'; import PropTypes from 'prop-types'; class Toast extends Component { componentDidMount() { const timeoutTime = this.props.type === 'error' ? 30000 : 5000; setTimeout(() => { this.props.removeToast(this.props.id); }, timeoutTime); } shouldComponentUpdate() { return false; } render() { return (

{this.props.message}

); } } Toast.propTypes = { id: PropTypes.string.isRequired, message: PropTypes.string.isRequired, type: PropTypes.string.isRequired, removeToast: PropTypes.func.isRequired, }; export default Toast;