-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Description
Describe the bug
Whenever component inside {#key}
gets remounted code inside <script>
tag executes earlier than the teardown code inside onDestroy
.
<script>
import { onMount, onDestroy, getAbortSignal } from 'svelte'
console.log('script')
onMount(() => {
console.log('mount')
const signal = getAbortSignal()
signal.addEventListener('abort', () => console.log('abort'))
})
onDestroy(() => {
console.log('destroy')
})
</script>
script
mount
script
abort
destroy
mount
To me personally thats a bit counter-intuitive. If we change something inside <script module>
for example then we can't rely on cleanup happening before new render.
Reproduction
Logs
System Info
irrelevant
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels