0
0
Vueframework~20 mins

Reactivity transform and limitations in Vue - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Reactivity Transform Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does reactivity transform affect ref unwrapping in templates?
Consider a Vue 3 component using reactivity transform. What will be the rendered output of the template if count is a ref initialized to 5 and incremented by 1 before rendering?
Vue
<script setup lang="ts" reactivitytransform>
let count = $ref(5)
count++
</script>
<template>
  <p>{{ count }}</p>
</template>
A<p>6</p>
B<p>5</p>
C<p>[object Object]</p>
D<p>undefined</p>
Attempts:
2 left
💡 Hint
Reactivity transform unwraps refs automatically in templates.
📝 Syntax
intermediate
2:00remaining
Which code snippet correctly uses reactivity transform to create a reactive object?
Select the code that correctly creates a reactive object using Vue's reactivity transform syntax.
Alet user = reactive({ name: 'Alice', age: 30 })
Blet user = $reactive({ name: 'Alice', age: 30 })
Clet user = $ref({ name: 'Alice', age: 30 })
Dlet user = ref({ name: 'Alice', age: 30 })
Attempts:
2 left
💡 Hint
Reactivity transform provides special prefixes for reactive primitives and objects.
🔧 Debug
advanced
2:30remaining
Why does this reactivity transform code fail to track changes?
Given the code below, why does updating state.count not trigger a template update?
Vue
<script setup lang="ts" reactivitytransform>
let state = { count: $ref(0) }
function increment() {
  state.count++
}
</script>
<template>
  <p>{{ state.count }}</p>
  <button @click="increment">Increment</button>
</template>
ABecause <code>$ref</code> cannot be used inside objects with reactivity transform.
BBecause the template does not unwrap nested refs automatically.
CBecause <code>state.count++</code> syntax is invalid with reactivity transform.
DBecause <code>state</code> is a plain object, not reactive, so changes to <code>count</code> are not tracked.
Attempts:
2 left
💡 Hint
Reactivity transform requires reactive wrappers for objects to track nested properties.
🧠 Conceptual
advanced
2:00remaining
What is a key limitation of Vue's reactivity transform regarding arrays?
Which statement best describes a limitation of reactivity transform when working with arrays?
AReactivity transform does not track mutations made by direct index assignment like <code>arr[0] = value</code>.
BReactivity transform disables reactivity for array methods like <code>push</code> and <code>pop</code>.
CReactivity transform requires arrays to be wrapped with <code>$ref</code> to be reactive.
DReactivity transform cannot unwrap refs inside arrays automatically.
Attempts:
2 left
💡 Hint
Think about how Vue tracks changes to array elements.
state_output
expert
2:30remaining
What is the final value of count after this reactivity transform code runs?
Analyze the code below and determine the final value of count after all statements execute.
Vue
<script setup lang="ts" reactivitytransform>
let count = $ref(1)
function update() {
  count += 2
  count = count * 3
}
update()
</script>
A6
B7
C9
D3
Attempts:
2 left
💡 Hint
Follow the arithmetic step by step.