react-snackbar-alert
Simple snackbar-style notifications for React.
Installation
npm install --save react-snackbar-alert
Usage
The basic usage is as follows:
- Import the SnackbarManagercomponent
- Import the CSS
- Add the SnackbarManagercomponent to your application'srendermethod and save it to a ref
- Call createon the ref to create snackbar alerts
Example
  import React from 'react';
  import { SnackbarManager } from 'react-snackbar-alert';
  import 'react-snackbar-alert/styles/react-snackbar-alert.css';
  export default class App extends React.Component {
    constructor(props) {
      super(props);
      this.snackbarManager = React.createRef();
      this.showAlert = this.showAlert.bind(this);
    }
    showAlert() {
      this.snackbarManager.current.create({
        message: 'Hello World!'
      });
    }
    render() {
      return (
        <main>
          <SnackbarManager ref={this.snackbarManager} />
          <button onClick={this.showAlert}>Show Alert</button>
        </main>
      )
    }
  }
Options
SnackbarManager Props
The SnackbarManager component accepts the following props:
- animationTimeout- The duration of the show and hide animations, in milliseconds (default: 500)
- component- A custom component to use instead of the built-in- Snackbarcomponent
- dismissable- Whether or not the created snackbars can be manually dismissed by the user
- pauseOnHover- Whether or not a snackbar's timeout should be paused when it is hovered over (default: false)
- progressBar- Whether or not to show an animated progress bar showing the time before a snackbar is removed (default: true)
- timeout- The time before a snackbar is removed, in milliseconds (default: 3000)
SnackbarManager.create Options
The create method of SnackbarManager accepts an options object, which can have the following properties:
- animationTimeout- The duration of the show and hide animations (overrides the timeout in- SnackbarManager)
- data- Custom data to use when rendering a custom snackbar
- dismissable- Whether or not this snackbar can be manually dismissed by the user
- message- The message to display
- pauseOnHover- Whether or not to pause this snackbar on hover
- progressBar- Whether or not to show the progress bar for this snackbar
- sticky- Whether or not this snackbar should be sticky. Sticky snackbars are not automatically removed.
- timeout- The time before this snackbar is removed (overrides the timeout in- SnackbarManager)
 
             
             
             
             
            