import React from 'react' import PropTypes from 'prop-types' import { animated, Transition } from 'react-spring' import { Box } from 'rebass' import errorToUserFriendly from 'lib/utils/userFriendlyErrors' import { Notification } from 'components/UI' class GlobalError extends React.Component { static propTypes = { error: PropTypes.string, clearError: PropTypes.func.isRequired } componentDidUpdate(prevProps) { const { clearError, error } = this.props if (!prevProps.error && error) { setTimeout(clearError, 10000) } } render() { const { error, clearError } = this.props return ( {show => show && (springStyles => ( {errorToUserFriendly(error)} )) } ) } } export default GlobalError