Skip to content
Discussion options

You must be logged in to vote

Thx 👍
We have similar patterns too.
If I remember correctly, inside $effect in List.svelte, when data changes, you can use a function instead of instructions, it should work. Not sure 100% though

// List.svelte
<script lang="ts">
  let { data } = $props()
  
  const table = new TableHandler(data)
  
  const update = () => {
    const page = table.currentPage
    table.setRows(data)
    table.setPage(page)
  } 
  $effect(() => {
    data // detects changes in data prop
    update() 
  })
</script>

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@leonardodipace
Comment options

Comment options

You must be logged in to vote
1 reply
@leonardodipace
Comment options

Answer selected by leonardodipace
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