0.1.95 • Published 2 years ago

tipddy-snackbar v0.1.95

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

tippdy-snackbar is a notification library which makes it extremely easy to display notifications on your web apps. It is highly customizable and enables you to stack snackbars/toasts on top of one another.

Table of Contents

Getting Started

Use your preferred package manager:

npm install tippdy-snackbar
yarn add tippdy-snackbar

How to use

1: Wrap your app inside a SnackProvider component:

import { SnackbarProvider } from "notistack";
<SnackbarProvider maxSnack={3}>
  <App />
</SnackbarProvider>;

2: Export any component that needs to send notification using withSnackbar. By doing this, you'll have access to methods enqueueSnackbar and closeSnackbar, where the former can be used to send snackbars.

import { withSnackbar } from "notistack";
class MyComponent extends Component {
  handleNetworkRequest = () => {
    fetchSomeData()
      .then(() => this.props.enqueueSnackbar("Successfully fetched the data."))
      .catch(() => this.props.enqueueSnackbar("Failed fetching data."));
  };
  render() {
    //...
  }
}
export default withSnackbar(MyComponent);

2 (alternative): You can use useSnackbar hook in your functional components as well.

import { useSnackbar } from "notistack";
const MyButton = () => {
  const { enqueueSnackbar, closeSnackbar } = useSnackbar();
  const handleClick = () => {
    enqueueSnackbar("I love hooks");
  };
  return <Button onClick={handleClick}>Show snackbar</Button>;
};

Online demo

Visit documentation website to see all the demos. Or play with a minimal working example: codesandbox

Redux and Mobx support:

notistack is compatible with state management libraries such as Redux and Mobx.

Contribution

Open an issue and your problem will be solved.

Author - Contact

Hossein Dehnokhalaji

0.1.95

2 years ago

0.1.94

2 years ago

0.1.93

2 years ago

0.1.92

2 years ago

0.1.91

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago