fix: replace $effect with onMount for initial data load
$effect re-runs on any reactive state change — loadData/loadConfig both write state, creating an infinite loop that hung the page under load.
This commit is contained in:
@@ -117,7 +117,9 @@
|
||||
"id": "another-group",
|
||||
"label": "Another Group",
|
||||
"baseUnitId": "",
|
||||
"toUniversal": 1
|
||||
"toUniversal": 1,
|
||||
"alwaysShowLabel": false,
|
||||
"hidden": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
import { getContext, onMount } from 'svelte';
|
||||
import type { Unit, Group, UnitsData } from '$lib/types';
|
||||
|
||||
const adminPath = getContext<string>('adminPath') ?? 'admin';
|
||||
@@ -239,7 +239,7 @@
|
||||
expandedGroups = new Set([...expandedGroups, ...groups.map((g) => g.id)]);
|
||||
}
|
||||
|
||||
$effect(() => { loadData(); loadConfig(); });
|
||||
onMount(() => { loadData(); loadConfig(); });
|
||||
|
||||
async function extractError(res: Response, fallback: string): Promise<string> {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
|
||||
Reference in New Issue
Block a user