Skip to content
Advertisement

Vue 3: computed property doesn’t track its dependency in composition API

Consider this illustrative example:

JavaScript
JavaScript

As you can see, message stores a computed value that should track updates to name but it isn’t.
Why is it like that and how to fix it?

Advertisement

Answer

Computed should always use an immutable reactive ref object you want to be computed.

so if you declare the reactive objects you are using at the beginning it will work.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement