Vue · Junior · Question 41 of 75
What is onUnmounted used for?
- ✓Correct answer: Cleaning up side effects: timers, event listeners on
window, subscriptions - 2Fetching initial data
- 3Updating props before rendering
Explanation
Anything set up manually in onMounted (setInterval, addEventListener) must be torn down in onUnmounted, or it keeps running and leaks memory.