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 { MdClose } from 'react-icons/lib/md'
import styles from './GlobalError.scss' import styles from './GlobalError.scss'
const GlobalError = ({ error, clearError }) => { class GlobalError extends React.Component {
setTimeout(clearError, 10000) componentDidUpdate(prevProps) {
if (!prevProps.error && this.props.error) {
setTimeout(this.props.clearError, 10000)
}
}
return ( render() {
<div className={`${styles.container} ${!error && styles.closed}`}> const { error, clearError } = this.props
<div className={styles.content}>
<div className={styles.close} onClick={clearError}> return (
<MdClose /> <div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}>
<div className={styles.close} onClick={clearError}>
<MdClose />
</div>
<h2>{error}</h2>
</div> </div>
<h2>{error}</h2>
</div> </div>
</div> )
) }
} }
GlobalError.propTypes = { GlobalError.propTypes = {
error: PropTypes.string, error: PropTypes.string,
clearError: PropTypes.func.isRequired clearError: PropTypes.func.isRequired

Loading…
Cancel
Save