Skip to content

⬅️ Back to Table of Contents

📄 useMounted

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 3

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useMounted/index.ts

📦 Imports

Name Source
getCurrentInstance vue
onMounted vue
shallowRef vue

Functions

useMounted(): any

Mounted state in ref.

See: https://vueuse.org/useMounted

Tags: @__NO_SIDE_EFFECTS__

Raw JSDoc
/**
 * Mounted state in ref.
 *
 * @see https://vueuse.org/useMounted
 *
 * @__NO_SIDE_EFFECTS__
 */

Calls:

  • shallowRef (from vue)
  • getCurrentInstance (from vue)
  • onMounted (from vue)
Code
export function useMounted() {
  const isMounted = shallowRef(false)

  const instance = getCurrentInstance()
  if (instance) {
    onMounted(() => {
      isMounted.value = true
    }, instance)
  }

  return isMounted
}

Generated by Syntax Scribe