{
static defaultProps = {
overflow: OVERFLOW_WRAP,
type: TYPE_DEFAULT,
};
componentDidMount() {
const { duration, onClose } = this.props;
this.timeout = duration && onClose ? setTimeout(onClose, DURATION_TIMES[duration]) : null;
}
onClose = event => {
const { onClose } = this.props;
if (this.timeout) {
clearTimeout(this.timeout);
}
if (onClose) {
onClose(event);
}
};
getChildren() {
const { children } = this.props;
return typeof children === 'string' ? {children} : children;
}
timeout: TimeoutID | null;
render() {
const contents = this.getChildren();
const { intl, type, overflow } = this.props;
const { formatMessage } = intl;
const classes = classNames('notification', type, overflow);
return (
{React.cloneElement(ICON_RENDERER[type](), {
color: '#fff',
height: 20,
width: 20,
})}
{contents}
);
}
}
export default injectIntl(Notification);