Created
April 10, 2024 18:56
-
-
Save helabenkhalfallah/73818c5c25506a8e3cd7df9a84caa139 to your computer and use it in GitHub Desktop.
Svelte Life Cycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { afterUpdate, beforeUpdate, onDestroy, onMount, tick } from 'svelte'; | |
onMount(() => { | |
console.log('the component has mounted'); | |
}); | |
beforeUpdate(() => { | |
console.log('the component is about to update'); | |
}); | |
afterUpdate(() => { | |
console.log('the component just updated'); | |
}); | |
onDestroy(() => { | |
console.log('the component is being destroyed'); | |
}); | |
beforeUpdate(async () => { | |
console.log('the component is about to update'); | |
await tick(); | |
console.log('the component just updated'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment