Bug: Toasts won't trigger anymore in v2.6.0 when using useToaster and useToasterStore is used in component which gets unmounted

Author: joonass-vismaCreated Sep 3, 2025Updated Oct 14, 2025

Steps to reproduce:

  1. Have Toaster component implemented with useToaster hook
  2. Have Toast component which reads toaster state using useToasterStore
  3. Fire toast
  4. Dismiss toast or wait for it to dismiss
  5. Try to fire another toast --> nothing happens

Suspected root cause: when Toast gets unmounted, it removes wrong listener from the global listener array. So instead of removing the listener that Toast added, it removes the listener that Toaster added, i.e. besides just checking toasterId, it should also verify we are removing correct listener.

typescript
// src/core/store.ts

useEffect(() => {
    // ...
    return () => {
      const index = listeners.findIndex(([id]) => id === toasterId); // <-- THE PROBLEM
      if (index > -1) {
        listeners.splice(index, 1);
      }
    };
  }, [toasterId]);

Source: timolins/react-hot-toast