minor fixes

This commit is contained in:
Sacha Weatherstone
2023-12-17 12:58:14 +10:00
parent e3aee4cebd
commit f7ba8ad967
14 changed files with 112 additions and 89 deletions
+7 -6
View File
@@ -1,4 +1,4 @@
import * as React from "react";
import { useEffect, useState, ReactNode } from "react";
import type { ToastActionElement, ToastProps } from "@components/UI/Toast.js";
@@ -7,8 +7,8 @@ const TOAST_REMOVE_DELAY = 1000000;
type ToasterToast = ToastProps & {
id: string;
title?: React.ReactNode;
description?: React.ReactNode;
title?: ReactNode;
description?: ReactNode;
action?: ToastActionElement;
};
@@ -109,7 +109,7 @@ export const reducer = (state: State, action: Action): State => {
),
};
}
case "REMOVE_TOAST":
case "REMOVE_TOAST": {
if (action.toastId === undefined) {
return {
...state,
@@ -120,6 +120,7 @@ export const reducer = (state: State, action: Action): State => {
...state,
toasts: state.toasts.filter((t) => t.id !== action.toastId),
};
}
}
};
@@ -166,9 +167,9 @@ function toast({ ...props }: Toast) {
}
function useToast() {
const [state, setState] = React.useState<State>(memoryState);
const [state, setState] = useState<State>(memoryState);
React.useEffect(() => {
useEffect(() => {
listeners.push(setState);
return () => {
const index = listeners.indexOf(setState);