0
0
Vueframework~20 mins

Why Vue performance matters - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Vue Performance Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does Vue's reactivity system affect component updates?
Consider a Vue 3 component using the Composition API with a reactive state. What happens when a reactive property changes?
Vue
<script setup>
import { reactive } from 'vue'
const state = reactive({ count: 0 })
function increment() {
  state.count++
}
</script>
<template>
  <button @click="increment">Count: {{ state.count }}</button>
</template>
AVue will not detect changes to 'state.count' because reactive objects don't track properties.
BThe entire component will re-render every time 'state.count' changes, regardless of usage.
COnly the parts of the template that use 'state.count' will re-render when it changes.
DThe component will throw an error because 'state' is not declared as a ref.
Attempts:
2 left
💡 Hint
Think about how Vue tracks dependencies to update only what is necessary.
state_output
intermediate
2:00remaining
What is the output when updating a reactive object in Vue?
Given the following Vue 3 setup, what will be displayed after clicking the button twice?
Vue
<script setup>
import { reactive } from 'vue'
const state = reactive({ items: [] })
function addItem() {
  state.items.push('item')
}
</script>
<template>
  <button @click="addItem">Add</button>
  <p>Items count: {{ state.items.length }}</p>
</template>
AItems count: 2
BThe component will not update because arrays are not reactive.
CItems count: 1
DItems count: 0
Attempts:
2 left
💡 Hint
Remember how Vue tracks changes in reactive arrays.
📝 Syntax
advanced
2:00remaining
Which option correctly uses Vue's