Svelte and chip click handler fail in loop

Apparently if I define a click event (with a parameter) on the Chip component within an “Each” loop, it calls my function N times when the loop is rendering.


{#each chips as c,i}

    <Chip outline={!c.checked} id={} on:click={clickChip(i)}>{}</Chip>


This will call my “ClickChip” function 20 times automatically if I have an array of 20 chips. The expected behavior is to only call it when I click it.

This works fine if I dont supply a parameter. Seems to be a bug.

Hmm… Seems to work as expected if I do this way:
on:click={() => clickChip(i)}