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. 29
      app/components/GlobalError/GlobalError.js

29
app/components/GlobalError/GlobalError.js

@ -3,22 +3,29 @@ 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)
}
}
return (
<div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}>
<div className={styles.close} onClick={clearError}>
<MdClose />
render() {
const { error, clearError } = this.props
return (
<div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}>
<div className={styles.close} onClick={clearError}>
<MdClose />
</div>
<h2>{error}</h2>
</div>
<h2>{error}</h2>
</div>
</div>
)
)
}
}
GlobalError.propTypes = {
error: PropTypes.string,
clearError: PropTypes.func.isRequired

Loading…
Cancel
Save