Vue · Middle · Question 8 of 75
Why is mutating state inside a computed getter a bug?
- ✓Correct answer: Computed getters must be pure; side effects make updates unpredictable and can cause infinite loops
- 2Computed getters run only on the server
- 3Mutations inside computed are silently ignored
Explanation
Vue may run the getter at any time (or not at all if nothing reads it). Use a watcher for side effects and keep computed purely derived.