Skip to content

Commit acfa1c8

Browse files
committed
clarify onMount returned functions
1 parent 49b6544 commit acfa1c8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

text/0001-reactive-assignments.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,13 @@ There are three other lifecycle functions required — `onMount` (similar to `on
317317
318318
onMount(() => {
319319
// this runs once, after the first `afterUpdate`
320+
321+
return function() {
322+
// this (optional) returned function runs on destroy,
323+
// allowing references (to timeouts etc) to stay within
324+
// the function, and preventing DOM-specific cleanup
325+
// code running in an SSR context
326+
};
320327
});
321328
</script>
322329
```

0 commit comments

Comments
 (0)