[priority: 4] use-toast.ts listener leak — duplicate listeners accumulate on every state change #74
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: 4 — High
File:
src/hooks/use-toast.ts, lines 175-182Description:
The
[state]dependency means every timestatechanges (every toast action), the effect re-runs: it pushes a newsetStatetolistenersand removes the old one. Over time, the same component gets multiple listeners, causing duplicate renders and toast duplication.Fix: Use
[]as dependency:Starting work on Issue 74: use-toast.ts listener leak — duplicate listeners accumulate on every state change. Fixing by changing [state] dependency to [].
Fixed: Changed
useEffectdependency from[state]to[]inuseToast(). This prevents duplicate listeners from accumulating on every state change.