Skip to main content
InterviewHubPRO
Section Overview
Q7

Question 7 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

14%
Vue.js & Composition API (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What are the essential Vue 3 Lifecycle Hooks?

junior LevelHooksLifecycleVue & Nuxt

In Simple Words: In the Composition API, lifecycle hooks are imported and invoked inside setup():

  • onMounted(): Component has finished initial rendering and DOM nodes are accessible. (Fetch initial API data, attach window listeners).
  • onUpdated(): DOM has updated following a reactive state mutation.
  • onUnmounted(): Component has been destroyed and removed from DOM. (Clean up timers, cancel network requests).
  • onErrorCaptured(): Error boundary hook catching child component errors.
  • Note: beforeCreate and created do not exist in <script setup> because code inside <script setup> executes during component creation naturally!