Skip to content

Commit

Permalink
Merge pull request #7 from manjushsh/develop
Browse files Browse the repository at this point in the history
Merge latest changes to main
  • Loading branch information
manjushsh authored Nov 7, 2022
2 parents 4581e0c + 61af8a9 commit 4e2c9d7
Show file tree
Hide file tree
Showing 5 changed files with 1,559 additions and 10,662 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# mui-simple-toast - Simplified toaster/snackbar for MUI
A Simpler MUI Toast.
This reduces code to single line compared to Actual Toast Code from MUI
```
<Snackbar open={open} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity="success" sx={{ width: '100%' }}>
This is a success message!
</Alert>
</Snackbar>
```

to

```
<MUISimpleToast toast={toast} setToast={setToast} />
```

# [Demo](https://codesandbox.io/s/mui-simple-toast-g5ei8i?file=/src/index.tsx)

Expand Down Expand Up @@ -30,7 +44,7 @@ fetch(url)

```
import React, { useEffect, useState } from 'react';
import MUISimpleToast, { defaultToast } from 'mui-simple-toast/cjs'
import MUISimpleToast, { defaultToast } from 'mui-simple-toast'
import './App.css';
function App() {
Expand Down Expand Up @@ -68,12 +82,11 @@ In return method of component, add ```<MUISimpleToast toast={toast} setToast={se
in index.js

```
import React, { createContext, useState } from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css';
import { defaultToast } from 'mui-simple-toast/cjs';
import { defaultToast } from 'mui-simple-toast';
/** Create a Context for Toast Wrapper*/
export const ToastContext = createContext(defaultToast)
Expand Down Expand Up @@ -102,7 +115,6 @@ root.render(
In your App/ Child Component, add

```
const { toast, setToast }: any = useContext(ToastContext)
```
Expand Down
Loading

0 comments on commit 4e2c9d7

Please sign in to comment.