From 35f4a264d6774bf43dd769a200fc2189e91bf6a7 Mon Sep 17 00:00:00 2001 From: crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Wed, 17 Jul 2024 21:19:04 +0800 Subject: [PATCH] fix: default duration (#6393) --- web/app/components/base/toast/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/components/base/toast/index.tsx b/web/app/components/base/toast/index.tsx index 903b6d29a7..3e13db5d7f 100644 --- a/web/app/components/base/toast/index.tsx +++ b/web/app/components/base/toast/index.tsx @@ -27,7 +27,6 @@ export const ToastContext = createContext({} as IToastContext) export const useToastContext = () => useContext(ToastContext) const Toast = ({ type = 'info', - duration, message, children, className, @@ -91,7 +90,7 @@ export const ToastProvider = ({ duration: 6000, } const [params, setParams] = React.useState(placeholder) - const defaultDuring = params.type === 'success' ? 3000 : 6000 + const defaultDuring = (params.type === 'success' || params.type === 'info') ? 3000 : 6000 const [mounted, setMounted] = useState(false) useEffect(() => { @@ -100,7 +99,7 @@ export const ToastProvider = ({ setMounted(false) }, params.duration || defaultDuring) } - }, [mounted]) + }, [defaultDuring, mounted, params.duration]) return { @@ -119,6 +118,7 @@ Toast.notify = ({ duration, className, }: Pick) => { + const defaultDuring = (type === 'success' || type === 'info') ? 3000 : 6000 if (typeof window === 'object') { const holder = document.createElement('div') const root = createRoot(holder)