Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

ArrayObserver.svelte

19 lines432 Bytes

1<script lang="ts">
2 import { untrack } from 'svelte'
3 import type { FieldWithValue } from '../../src/index.js'
4​
5 interface Props {
6 field: FieldWithValue<Array<{ name: string }>>
7 }
8​
9 const { field }: Props = $props()
10 let runs = $state(0)
11​
12 $effect(() => {
13 field.value
14 untrack(() => runs++)
15 })
16</script>
17​
18<span data-testid="array-runs">{runs}</span>
19<span data-testid="array-length">{field.value.length}</span>