A
A
Andrew2020-05-28 00:06:05
Vue.js
Andrew, 2020-05-28 00:06:05

Why isn't computed updated?

budgets() {
            const type = this.type
            const budgets = this.$store.getters['budgets/all']
            const filtered_budgets = budgets.filter(budget => budget.type === type)

            console.log('TYPE', type)
            console.log('BUDGETS', {
                budgets,
                filtered_budgets
            })
            return filtered_budgets
},


console.log is triggered as expected when this.type changes. However, the returned array remains the same (the result of the first operation is returned, i.e. the array filtered by this.type: null).

UPD:
In addition, when a new entry in the budgets array appears in vuex, it is also not displayed. Now I'm reading similar questions, and it seems like it shouldn't work, but for some reason it seems that it always worked)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2020-05-28
@AndrewRusinas

The question is removed, because. the problem was in the component that takes this value - inside it, the array was copied and written to an internal variable. Corrected, computed now works as expected)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question