Browse Source

hotfix(global error): only setTimeout when theres an error

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
e51a2042df
  1. 13
      app/components/GlobalError/GlobalError.js

13
app/components/GlobalError/GlobalError.js

@ -3,8 +3,15 @@ import PropTypes from 'prop-types'
import { MdClose } from 'react-icons/lib/md'
import styles from './GlobalError.scss'
const GlobalError = ({ error, clearError }) => {
setTimeout(clearError, 10000)
class GlobalError extends React.Component {
componentDidUpdate(prevProps) {
if (!prevProps.error && this.props.error) {
setTimeout(this.props.clearError, 10000)
}
}
render() {
const { error, clearError } = this.props
return (
<div className={`${styles.container} ${!error && styles.closed}`}>
@ -16,9 +23,9 @@ const GlobalError = ({ error, clearError }) => {
</div>
</div>
)
}
}
GlobalError.propTypes = {
error: PropTypes.string,
clearError: PropTypes.func.isRequired

Loading…
Cancel
Save