Skip to content

Commit 348bfff

Browse files
perf(svelte): simplify watcher
1 parent 14e6287 commit 348bfff

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/svelte/src/lib/UnLazyImage.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { onDestroy, onMount } from 'svelte'
2+
import { onDestroy } from 'svelte'
33
import { lazyLoad } from 'unlazy'
44
55
/** Image source URL to be lazy-loaded. */
@@ -22,13 +22,8 @@
2222
2323
let target: HTMLImageElement | undefined
2424
let cleanup: (() => void) | undefined
25-
let isMounted = false
2625
27-
onMount(() => {
28-
isMounted = true
29-
})
30-
31-
$: if (isMounted && target) {
26+
$: if (target) {
3227
cleanup?.()
3328
3429
cleanup = lazyLoad(target, {

0 commit comments

Comments
 (0)