fix the toast system?
This commit is contained in:
@@ -10,7 +10,6 @@ import React from 'react';
|
|||||||
import Slide, { SlideProps } from '@material-ui/core/Slide';
|
import Slide, { SlideProps } from '@material-ui/core/Slide';
|
||||||
import Snackbar from '@material-ui/core/Snackbar';
|
import Snackbar from '@material-ui/core/Snackbar';
|
||||||
import MuiAlert, { Color as Severity } from '@material-ui/lab/Alert';
|
import MuiAlert, { Color as Severity } from '@material-ui/lab/Alert';
|
||||||
import cloneObject from 'util/cloneObject';
|
|
||||||
|
|
||||||
function removeToast(id: string) {
|
function removeToast(id: string) {
|
||||||
const container = document.querySelector(`#${id}`)!!;
|
const container = document.querySelector(`#${id}`)!!;
|
||||||
@@ -68,14 +67,10 @@ export function makeToaster(
|
|||||||
(arg0: React.ReactElement[]) => void],
|
(arg0: React.ReactElement[]) => void],
|
||||||
): [React.ReactElement[], ((message: string, severity: Severity) => void)] {
|
): [React.ReactElement[], ((message: string, severity: Severity) => void)] {
|
||||||
return [toasts, (message: string, severity: Severity) => {
|
return [toasts, (message: string, severity: Severity) => {
|
||||||
const curToasts = cloneObject(toasts);
|
setToasts([<Toast
|
||||||
curToasts.push(
|
key={Math.floor(Math.random() * 1000) + 1}
|
||||||
<Toast
|
message={message}
|
||||||
key={Math.floor(Math.random() * 1000) + 1}
|
severity={severity}
|
||||||
message={message}
|
/>]);
|
||||||
severity={severity}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
setToasts(curToasts);
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user