vue-sonner icon indicating copy to clipboard operation
vue-sonner copied to clipboard

Computed ref `filteredToasts` is returning a function (anti-pattern)

Open pcoterecollective opened this issue 9 months ago • 0 comments

https://github.com/xiaoluoboding/vue-sonner/blob/ada95d7d1edaa23a342115fa33d79f7047ca28b7/src/packages/Toaster.vue#L214

This is an anti-pattern: function returns are already cached.

Using a simple function should be sufficient:

const filteredToasts = (pos: string, index: number) => {
  return toasts.value.filter((toast) => (!toast.position && index === 0) || toast.position === pos)
}

pcoterecollective avatar Mar 24 '25 15:03 pcoterecollective