OSDN Git Service

auto disappear message in 5s https://github.com/Bytom/bytom/issues/840
authorZhiting Lin <zlin035@uottawa.ca>
Sat, 28 Apr 2018 03:49:15 +0000 (11:49 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Sat, 28 Apr 2018 03:49:15 +0000 (11:49 +0800)
src/features/shared/components/Flash/Flash.jsx

index 61d3923..28ce269 100644 (file)
@@ -62,6 +62,9 @@ class Flash extends React.Component {
       const item = props.messages[key]
       if (!item.displayed) {
         this.props.markFlashDisplayed(key)
+        setTimeout(() => {
+          this.props.dismissFlash(key)
+        }, 5000)
       }
     })
   }
@@ -71,10 +74,14 @@ class Flash extends React.Component {
       const item = nextProps.messages[key]
       if (!item.displayed) {
         this.props.markFlashDisplayed(key)
+        setTimeout(() => {
+          this.props.dismissFlash(key)
+        }, 5000)
       }
     })
   }
 
+
   render() {
     if (!this.props.messages || this.props.hideFlash) {
       return null