🦀 ClawHub
Vue
by @ivangdavila
Avoid common Vue mistakes — reactivity traps, ref vs reactive, computed timing, and Composition API pitfalls.
TERMINAL
clawhub install vue📖 About This Skill
name: Vue slug: vue version: 1.0.1 description: Build Vue 3 applications with Composition API, proper reactivity patterns, and production-ready components. metadata: {"clawdbot":{"emoji":"💚","requires":{"bins":["node"]},"os":["linux","darwin","win32"]}}
When to Use
User needs Vue expertise — from Composition API patterns to production optimization. Agent handles reactivity, component design, state management, and performance.
Quick Reference
| Topic | File |
|-------|------|
| Reactivity patterns | reactivity.md |
| Component patterns | components.md |
| Composables design | composables.md |
| Performance optimization | performance.md |
Composition API Philosophy
is the recommended syntax—cleaner and better performanceReactivity Traps
ref for primitives—access with .value in script, auto-unwrapped in templatereactive can't reassign whole object—state = {...} breaks reactivityreactive loses reactivity—use toRefs(state) to preservearr[0] = x works, unlike Vue 2reactive({count: ref(0)}).count is number, not refWatch vs Computed
computed for derived state—cached, recalculates only when dependencies changewatch for side effects—when you need to DO something in response to changescomputed should be pure—no side effects, no asyncwatchEffect for immediate reaction with auto-tracked dependenciesWatch Traps
deep: true—or watch a getter functionwatch is lazy by default—use immediate: true for initial runwatch(source, (newVal, oldVal) => {})watchEffect can't access old value—use watch if you need old/new comparisonconst stop = watch(...); stop()Props and Emits Traps
defineProps for type-safe props—defineProps<{ msg: string }>()defineEmits for type-safe events—defineEmits<{ (e: 'update', val: string): void }>()v-model is :modelValue + @update:modelValue—custom v-model with defineModel()default: () => ({})Template Ref Traps
ref="name" + const name = ref(null)—names must match exactlyonMounted, not during setupref on component gives component instance—ref on element gives DOM elementv-for becomes array of refsLifecycle Traps
onMounted for DOM access—component mounted to DOMonUnmounted for cleanup—subscriptions, timers, event listenersonBeforeMount runs before DOM insert—rarely needed but exists wrapperProvide/Inject Traps
provide('key', value) in parent—inject('key') in any descendantinject('key', defaultVal)—third param for factory functionVue Router Traps
useRoute for current route—reactive, use in setupuseRouter for navigation—router.push('/path')beforeEach, beforeResolve, afterEach—return false to cancel with named views—multiple views per routeCommon Mistakes
v-if vs v-show—v-if removes from DOM, v-show toggles displayv-for required—v-for="item in items" :key="item.id".prevent.stop vs .stop.prevent renders outside component tree⚡ When to Use
User needs Vue expertise — from Composition API patterns to production optimization. Agent handles reactivity, component design, state management, and performance.