Skip to content

Re-render table rows on data change in SvelteKit #105

Answered by bryanmylee
jakob-fuchs2 asked this question in Q&A
Discussion options

You must be logged in to vote

Svelte Headless Table uses stores for reactivity. You need to update that store whenever the page data changes to inform Svelte Headless Table of the data change.

It's an unfortunate consequence of Svelte's separation between component reactivity ($:) and external tooling reactivity (stores).

<script lang="ts">
  export let data;
  const manufacturers = writable(data.manufacturers);
  // Update the data store whenever `data` changes.
  $: $manufacturers = data.manufacturers;
  
  const table = createTable(manufacturers, {...});
  // ...
</script>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jakob-fuchs2
Comment options

Answer selected by jakob-fuchs2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants