mx-react-toaster 
A simple react toaster component
This is a corrected fork of react-alert.
Installation
$ npm install mx-react-toaster
It expects external react
, react-dom
and react-addons-css-transition-group
.
Usage
To use it, you have to import the AlertContainer
component, like this:
import React from 'react';
import AlertContainer from 'mx-react-toaster';
export default class App extends React.Component {
constructor(props){
super(props);
this.alertOptions = {
offset: 14,
position: 'bottom left',
theme: 'dark',
time: 5000,
transition: 'scale'
};
}
showAlert(){
this.msg.show('Some text or component', {
time: 2000,
type: 'success',
icon: <img src="path/to/some/img/32x32.png" />
});
}
render(){
return(
<div>
<AlertContainer ref={a => this.msg = a} {...this.alertOptions} />
<button onClick={this.showAlert.bind(this)}>Show Alert</button>
</div>
);
}
}
Options
The AlertContainer
component accepts the following options:
{
offset: 14,
position: 'bottom left',
theme: 'dark',
time: 5000,
transition: 'scale'
}
When you call the show
method, you can include the following options as a second parameter:
{
time: 0,
type: 'info',
icon: <img src="path/to/some/img/32x32.png" />
}
Api
Once you have the reference of the AlertContainer
you can call the following methods:
this.msg.show('Some message or component');
this.msg.info('Some info message or component');
this.msg.success('Some success message or component');
this.msg.error('Some error message or component');
this.msg.removeAll();
Using React Components as alert content
You can also use a React Component to show a alert message, like this:
this.msg.show(<AComponent aProp="some message" />);