Fix Daily Word stuck on "Loading…" (infinite reload loop)
The variant-watch $effect read `loading`, but load() flips `loading` false at the end — which re-fired the effect, which called load() again, forever. The board never rendered. Effect now tracks ONLY `variant`, so it loads once on mount and once per variant toggle. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { getJSON } from '$lib/api.js';
|
||||
|
||||
let { variant = '5', onstatus } = $props();
|
||||
@@ -143,8 +142,12 @@
|
||||
else navigator.clipboard?.writeText(text).then(() => { copied = true; setTimeout(() => (copied = false), 1500); });
|
||||
}
|
||||
|
||||
onMount(load);
|
||||
$effect(() => { variant; if (!loading) load(); }); // reload when the variant toggles
|
||||
// Load on mount and whenever the variant toggles. Tracks ONLY `variant` — it
|
||||
// must not depend on `loading`, or load()'s own loading flip would re-fire it.
|
||||
$effect(() => {
|
||||
variant;
|
||||
load();
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeydown} />
|
||||
|
||||
Reference in New Issue
Block a user