react-short-notice
Version:
react component alert or error short notice
69 lines (51 loc) • 1.43 kB
Markdown
in use es6
```
npm install react-short-notice --save
```
```
ShortNoticeContainer.jsx
ShortNoticeContraller.js
```
ShortNoticeContraller.jsx call => Listener ShortNoticeContainer.js
[](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent)
```
import {ShortNoticeController, ShortNoticeContainer} from 'react-short-notice'
class Container extends React.Component {
componentDidMount(){
ShortNoticeController.show('inErrorMessage')
setTimeout(()=>{
ShortNoticeController.show('shortNotice')
},2000)
setTimeout(()=>{
ShortNoticeController.hide('shortNotice')
},4000)
setTimeout(()=>{
ShortNoticeController.hide('sparkle')
},6000)
//all hide short notice
ShortNoticeController.allHide()
}
render(){
return(
<div>
<ShortNoticeContainer id='inErrorMessage' timeout='2000'>
<span>error message</span>
</ShortNoticeContainer>
<ShortNoticeContainer id='shortNotice'>
<span>shortNotice</span>
</ShortNoticeContainer>
<ShortNoticeContainer id='sparkle' transition='2s' timeout='2000'>
<span>shortNotice</span>
</ShortNoticeContainer>
</div>
)
}
}
```