Vue · Senior · Question 51 of 75

What does the previous argument of a computed getter (Vue 3.4+) allow?

const max = computed((previous) => {
  const next = Math.max(...values.value)
  return previous !== undefined && previous > next ? previous : next
})

Explanation

Returning the old object when nothing meaningful changed keeps references stable for downstream computeds and watchers.

Further reading

Problem with a question

Vue · Senior · question 51

Test yourself

Take the Vue · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz