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.
- Host: GitHub
- URL: https://github.com/perfectbase/dialog-and-snackbar-react
- Owner: perfectbase
- Created: 2022-06-30T11:51:28.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-30T15:17:17.000Z (almost 4 years ago)
- Last Synced: 2025-07-11T10:36:34.006Z (11 months ago)
- Topics: material-ui, nextjs, reactjs
- Language: TypeScript
- Homepage:
- Size: 82 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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