File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " svelte-sonner " : patch
3
+ ---
4
+
5
+ Avoid triggering nested $effect updates on dismissal
Original file line number Diff line number Diff line change 186
186
187
187
initialHeight = finalHeight ;
188
188
189
- toastState .setHeight ({ toastId: toast .id , height: finalHeight });
189
+ // setHeight reads heights and toasts state. Untrack the call
190
+ // to avoid triggering this effect when those are modified. e.g. toasts
191
+ // added and removed.
192
+ untrack (() => {
193
+ toastState .setHeight ({ toastId: toast .id , height: finalHeight });
194
+ });
190
195
});
191
196
192
197
function deleteToast() {
265
270
266
271
$effect (() => {
267
272
if (toast .delete ) {
268
- deleteToast ();
273
+ // deleteToast reads and writes the heights and toasts state.
274
+ // Untrack the call to avoid triggering nested updates.
275
+ // See https://github.com/wobsoriano/svelte-sonner/issues/151
276
+ untrack (() => {
277
+ deleteToast ();
278
+ });
269
279
}
270
280
});
271
281
You can’t perform that action at this time.
0 commit comments