File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/svelte/src/internal/client/reactivity Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -185,8 +185,12 @@ export function update_derived(derived) {
185
185
// that also happens before user_effect teardown.
186
186
//
187
187
// store old value only if not inside a teardown function
188
- // because in legacy mode, bindable props are deriveds
189
- // and they are executed during teardown.
188
+ // because we only need to save the old values before
189
+ // the cleanup is triggered othewise accessing
190
+ // a derived during cleanup will return the incorrect
191
+ // value in case the derived wasn't in the deps of the effect,
192
+ // or the teardown was executed because the component was
193
+ // destroyed.
190
194
if ( ! is_destroying_effect ) {
191
195
var old_value = derived . v ;
192
196
old_values . set ( derived , old_value ) ;
You can’t perform that action at this time.
0 commit comments