fix toast

This commit is contained in:
Zhang Minghan 2023-10-25 17:20:50 +08:00
parent c2668212f6
commit 4951906fcb
2 changed files with 3 additions and 2 deletions

View File

@ -29,7 +29,6 @@ import {
Dialog, Dialog,
DialogContent, DialogContent,
DialogDescription, DialogDescription,
DialogFooter,
DialogHeader, DialogHeader,
DialogTitle, DialogTitle,
DialogTrigger DialogTrigger

View File

@ -137,7 +137,7 @@ function dispatch(action: Action) {
type Toast = Omit<ToasterToast, "id">; type Toast = Omit<ToasterToast, "id">;
function toast({ ...props }: Toast) { function toast({ ...props }: Toast, timeout?: number) {
const id = genId(); const id = genId();
const update = (props: ToasterToast) => const update = (props: ToasterToast) =>
@ -147,6 +147,8 @@ function toast({ ...props }: Toast) {
}); });
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id }); const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
setTimeout(dismiss, timeout ?? 5000);
dispatch({ dispatch({
type: "ADD_TOAST", type: "ADD_TOAST",
toast: { toast: {