File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
packages/svelte/src/internal/client/reactivity Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,8 @@ export function unset_context(is_component_body = false) {
177177 if ( DEV ) set_from_async_derived ( null ) ;
178178}
179179
180+ export let running_deferred_effects = false ;
181+
180182/**
181183 * @param {() => Promise<void> } fn
182184 * @param {boolean } [is_component]
@@ -198,7 +200,9 @@ export async function async_body(fn, is_component = false) {
198200 if ( ctx !== null ) {
199201 console . log ( 'hi' ) ;
200202 ctx . a = false ;
203+ running_deferred_effects = true ;
201204 pop ( ) ;
205+ running_deferred_effects = false ;
202206 }
203207 }
204208}
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ import { define_property } from '../../shared/utils.js';
4141import { get_next_sibling } from '../dom/operations.js' ;
4242import { component_context , dev_current_component_function , dev_stack } from '../context.js' ;
4343import { Batch , schedule_effect } from './batch.js' ;
44- import { flatten } from './async.js' ;
44+ import { flatten , running_deferred_effects } from './async.js' ;
4545import { without_reactive_context } from '../dom/elements/bindings/shared.js' ;
4646
4747/**
@@ -207,7 +207,11 @@ export function user_effect(fn) {
207207 // Non-nested `$effect(...)` in a component should be deferred
208208 // until the component is mounted
209209 var flags = /** @type {Effect } */ ( active_effect ) . f ;
210- var defer = ! active_reaction && ( flags & BRANCH_EFFECT ) !== 0 && ( flags & EFFECT_RAN ) === 0 ;
210+ var defer =
211+ ! active_reaction &&
212+ ( flags & BRANCH_EFFECT ) !== 0 &&
213+ ( flags & EFFECT_RAN ) === 0 &&
214+ ! running_deferred_effects ;
211215
212216 if ( defer ) {
213217 // Top-level `$effect(...)` in an unmounted component — defer until mount
You can’t perform that action at this time.
0 commit comments