Question · Svelte and SvelteKit course · Module 7: Lifecycle

Cleanup in onMount

How do you perform cleanup in onMount?

Answer options

  • Call onDestroy inside onMount
  • Return a function from onMount
  • Use a finally block
  • Cleanup happens automatically

You can check the correct answer by solving this task in the CodeWorlds game.