Skip to content

Commit 0eafed1

Browse files
committed
better fix
1 parent 20ae428 commit 0eafed1

File tree

1 file changed

+7
-4
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+7
-4
lines changed

packages/svelte/src/internal/client/dom/blocks/each.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
205205

206206
if (!hydrating) {
207207
reconcile(array, state, anchor, render_fn, flags, get_key);
208-
// Reconciling can cause the collection to become unstable if any inner effects
209-
// have mutated the collection since reconcialtion. Reading the collection again
210-
// will fix this
211-
get_collection();
212208
}
213209

214210
if (fallback_fn !== null) {
@@ -229,6 +225,13 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
229225
// continue in hydration mode
230226
set_hydrating(true);
231227
}
228+
229+
// When we mount the each block for the first time, the collection won't be
230+
// connected to this effect as the effect hasn't finished running yet and its deps
231+
// won't be assigned. However, it's possible that when reconciling the each block
232+
// that a mutation occured and it's made the collection MAYBE_DIRTY, so reading the
233+
// collection again can provide consistency to the reactive grpah again
234+
get_collection();
232235
});
233236

234237
if (hydrating) {

0 commit comments

Comments
 (0)