Skip to content

Commit 0e2a6a5

Browse files
committed
Fix custom component props not reactive (#51)
1 parent a7b1a4c commit 0e2a6a5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/ToastItem.svelte

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ const resume = () => {
4040
}
4141
}
4242
43-
const getProps = () => {
43+
let componentProps = {}
44+
$: if (item.component) {
4445
const { props = {}, sendIdTo } = item.component
45-
if (sendIdTo) {
46-
props[sendIdTo] = item.id
47-
}
48-
return props
46+
componentProps = { ...props, ...(sendIdTo && { [sendIdTo]: item.id }) }
4947
}
5048
5149
// `progress` has been renamed to `next`; shim included for backward compatibility, to remove in next major
@@ -63,7 +61,7 @@ onDestroy(() => {
6361
<div class="_toastItem" class:pe={item.pausable} on:mouseenter={pause} on:mouseleave={resume}>
6462
<div role="status" class="_toastMsg" class:pe={item.component}>
6563
{#if item.component}
66-
<svelte:component this={item.component.src} {...getProps()} />
64+
<svelte:component this={item.component.src} {...componentProps} />
6765
{:else}
6866
{@html item.msg}
6967
{/if}

0 commit comments

Comments
 (0)