An open API service indexing awesome lists of open source software.

https://github.com/perfectbase/dialog-and-snackbar-react

How to use Context to facilitate calling a Dialog or Snackbar.
https://github.com/perfectbase/dialog-and-snackbar-react

material-ui nextjs reactjs

Last synced: about 1 month ago
JSON representation

How to use Context to facilitate calling a Dialog or Snackbar.

Awesome Lists containing this project

README

          

## About the project

This project uses Context Provider and Promise so you can easily call a modal or a Snackbar from anywhere in the app.

```typescript
// ...
const showDialog = useDialog();
const showSnackbar = useSnackbar();

const handleShowDialog = async () => {
const confirmed = await showDialog({
title: 'Custom Dialog',
message: 'Custom message...',
});
if (confirmed) {
showSnackbar('Confirmed!', 'success');
} else {
showSnackbar('Canceled!', 'error');
}
};
// ...
```

## Check the article

https://blog.perfect-base.com/react-dialog-snackbar