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 { 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)
}
}
render() {
const { error, clearError } = this.props
return ( return (
<div className={`${styles.container} ${!error && styles.closed}`}> <div className={`${styles.container} ${!error && styles.closed}`}>
@ -16,9 +23,9 @@ const GlobalError = ({ error, clearError }) => {
</div> </div>
</div> </div>
) )
}
} }
GlobalError.propTypes = { GlobalError.propTypes = {
error: PropTypes.string, error: PropTypes.string,
clearError: PropTypes.func.isRequired clearError: PropTypes.func.isRequired

Loading…
Cancel
Save