🍫 React Snackbar Alert

Pause on Hover

Pause on Hover will pause a snackbar's timeout when the mouse is hovered over it. This is disabled by default. It can be enabled in one of two ways:

  • Setting the pauseOnHover prop on the SnackbarProvider for all snackbars
  • Setting the pauseOnHover property on the object passed to createSnackbar for a specific snackbar
import React from 'react';

import { SnackbarProvider, wrapComponent } from 'react-snackbar-alert';

export default function PauseOnHoverExample() {
  return (
    <SnackbarProvider pauseOnHover={true}>
      <Container />
    </SnackbarProvider>
  );
}

const Container = wrapComponent(function({ createSnackbar }) {
  function showSnackbar() {
    createSnackbar({
      message: 'Hello Snackbar!'
    });
  }

  return (
    <div>
      <button onClick={showSnackbar}>Show Snackbar</button>
    </div>
  );
});