-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
When I run this tutorial code: https://docs.svar.dev/svelte/grid/getting_started/
Then Svelte throws a 500 error.
As far as I can tell, there's a mount timing issue in Svelte 5 that's causing the grid to fail. What I see is if I edit the page HTML then the grid loads, then if I reload in the browser, the grid fails with a 500 error.
This fix solves it for me. Is there a better way? Thank you.
<script>
// Import the SVAR Svelte DataGrid
import { Grid } from "@svar-ui/svelte-grid";
// Apply the SVAR prebuilt theme named Willow.
import { Willow } from "@svar-ui/svelte-grid";
const columns = [{
id: "id",
width: 50,
header: "Id",
footer: "Id",
},
{
id: "name",
width: 100,
header: "Name",
footer: "Name",
},
];
const data = [{
id: 1,
name: "Alice",
},
{
id: 2,
name: "Bob",
},
];
// Fix for Svelte 5 and SVAR Svelte DataGrid.
let mounted = $state(false);
import { onMount } from "svelte";
onMount(() => { mounted = true; });
</script>
<!-- Apply the SVAR prebuilt theme named Willow. -->
<Willow>
<!-- Wait for the data to be loaded because of timing. -->
{#if mounted}
<!-- Render the SVAR Svelte DataGrid. -->
<Grid {data} {columns} />
{/if}
</Willow>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels