Skip to content

Commit c5e8f7b

Browse files
committed
fix(toast): restore useMemo for context value to prevent unnecessary re-renders
1 parent e8c37ea commit c5e8f7b

File tree

1 file changed

+5
-1
lines changed
  • apps/sim/components/emcn/components/toast

1 file changed

+5
-1
lines changed

apps/sim/components/emcn/components/toast/toast.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
useCallback,
77
useContext,
88
useEffect,
9+
useMemo,
910
useRef,
1011
useState,
1112
} from 'react'
@@ -197,7 +198,10 @@ export function ToastProvider({ children }: { children?: ReactNode }) {
197198
}
198199
}, [addToast])
199200

200-
const ctx: ToastContextValue = { toast: toastFn.current, dismiss: dismissToast }
201+
const ctx = useMemo<ToastContextValue>(
202+
() => ({ toast: toastFn.current, dismiss: dismissToast }),
203+
[dismissToast]
204+
)
201205

202206
return (
203207
<ToastContext.Provider value={ctx}>

0 commit comments

Comments
 (0)