All skills
onmax avatar

/vue-debug-guides

@de09c7b official
by Maxonmax/nuxt-skills715 stars
38

Vue 3 debugging and error handling for runtime errors, warnings, async failures, and SSR/hydration issues. Use when diagnosing or fixing Vue issues.

Use this Skill: https://skilld.dev/gh/onmax/nuxt-skills/vue-debug-guides

This session only. Nothing lands on disk.

referencereactive-destructuring.md

≈669 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Never Destructure reactive() Objects Directly

Impact: HIGH - Destructuring a reactive() object breaks the reactive connection. Updates to destructured variables won't trigger UI updates, leading to stale data display.

Vue's reactive() uses JavaScript Proxies to track property access. When you destructure, you extract primitive values from the proxy, losing the reactive connection. This is especially dangerous when destructuring from composables or imported state.

Task Checklist

  • Never destructure reactive objects directly if you need reactivity
  • Use toRefs() to convert reactive object properties to refs before destructuring
  • Consider using ref() instead of reactive() to avoid this pitfall entirely
  • When importing state from composables, check if it's reactive before destructuring

Incorrect:

import { reactive } from 'vue'

const state = reactive({
  count: 0,
  name: 'Vue'
})

// WRONG: Destructuring breaks reactivity
const { count, name } = state

// These updates work on the original state...
state.count++  // state.count is now 1

// ...but the destructured variables are NOT updated
console.log(count)  // Still 0! Lost reactivity
// WRONG: Destructuring from a composable
function useCounter() {
  const state = reactive({ count: 0 })
  return state
}

const { count } = useCounter()  // count is now a non-reactive primitive

Correct:

import { reactive, toRefs } from 'vue'

const state = reactive({
  count: 0,
  name: 'Vue'
})

// CORRECT: Use toRefs() to maintain reactivity
const { count, name } = toRefs(state)

state.count++
console.log(count.value)  // 1 - Reactivity preserved! (note: now needs .value)
// CORRECT: Return toRefs from composables
function useCounter() {
  const state = reactive({ count: 0 })
  return toRefs(state)  // Now safe to destructure
}

const { count } = useCounter()  // count is now a ref, reactivity preserved
// ALTERNATIVE: Just use ref() to avoid the issue entirely
import { ref } from 'vue'

const count = ref(0)
const name = ref('Vue')

// No destructuring needed, no gotchas

Reference

Source: SKILL.md on GitHub

No alerts9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    The skill is a comprehensive collection of Vue 3 debugging guides and best practices. It contains no malicious code, exfiltration attempts, or prompt injections.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

Signed by skilld at de09c7b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated last week

README badge

README badge for onmax/nuxt-skills/vue-debug-guides