react-toastr
React.js toastr component
Installation
npm install react-toastr2
Demo
Static hosted demo site on GitHub.
Example
Check src/app folder.
Usage
This module requires to be bundled with webpack/browserify and loads react/addons
internally.
You'll need to download animate.css from here Animate @github
Link to css for styles:
Then:
var ReactToastr = ;var ToastContainer = ReactToastr; // This is a React Element.// For Non ES6...// var ToastContainer = ReactToastr.ToastContainer;var ToastMessageFactory = React; // In a react component: { return <div> <ToastContainer ref="container" toastMessageFactory=ToastMessageFactory className="toast-top-right" /> <button onClick=thisaddAlert>GGininder</button> </div> ; }
Here's a list of React Elements:
ToastContainer
This is the container where all ToastMessage
elements will go. Use it by retaining a ref to publish a new toast message:
{ thisrefscontainer; window; }
or integrated with your flux architecture?
{ InInDerStore; }
Options
Directly migrated from toastr.js
library, and can be overrided via props
in a React way:
ToastContainer::getDefaultProps
Close Button
The close button on the toastr is an optional functionality.
closeButton:true
Time Out
Set the time(in ms) after which the toastr message should automatically close.
timeOut:5000
Prevent Duplicates
This prevents duplicate messages from getting triggered.
preventDuplicates:true
Displaying HTML
To display HTML simply pass JSX instead of strings for title and message arguments:
thisrefscontainer;
ToastMessage
Base class for holding a toast message, it will not animate in and out during it's lifecycle.
Provides ToastMessage.animation
and ToastMessage.jQuery
for your choice.
Options
Directly migrated from toastr.js
library, and can be overrided via props
in a React way: