Subscribe on changes!

Warn when calling computed/ref inside a computed callback

avatar
Mar 10th 2023

What problem does this feature solve?

Calling computed inside of another computed causes a "memory leak". As explained here #6994, this is not Vue's fault since this is misusage of the API.

However, would it be possible to add a warning in development when a reactive function (ref/computed/etc) is called inside the scope of a computed callback?

const msg = ref('Hello World!')
const msgPlus2 = computed(() => {
  const msgPlus1 = computed(() => msg.value + 1) // This should warn in dev
  return msgPlus1.value + 1
})

What does the proposed API look like?

Warning in dev only