Reputation: 4330
I am facing one issue, where after updating my store value isRenewalFlow
my component is not getting updated.
On debugging I found component's updated
life cycle is not getting called after mutation [MUTATION_TYPES.IS_RENEWAL_FLOW]
updates store value. Even getIsRenewalFlow
in store getter is only called once in the beginning and not after store update inside mutations.
Here's the code.
Store
const state = {
isRenewalFlow: undefined,
}
const getters = {
getIsRenewalFlow: (state) => state.isRenewalFlow,
}
const actions = {
[ACTION_TYPES.POPULATE_QUOTE_DATA]: (
{ dispatch, commit, state, rootState, getters }, payload
) => {
commit(MUTATION_TYPES.IS_RENEWAL_FLOW, payload)
}
}
const mutations = {
[MUTATION_TYPES.IS_RENEWAL_FLOW]: (state, payload) => {
state.isRenewalFlow = payload
},
}
Component
export default Vue.extend({
components: {
ErrorBoundary: () => import('@/components/common/ErrorBoundary.vue'),
},
computed: {
...mapGetters({
getIsRenewalFlow: 'getIsRenewalFlow',
}),
},
mounted() {
this.getIsRenewalFlow !== undefined &&
someFunc()
},
updated() {
this.getIsRenewalFlow !== undefined &&
someFunc()
},
})
someFunc
is never getting called even after updating state.isRenewalFlow
with true
or false
inside mutations
[MUTATION_TYPES.IS_RENEWAL_FLOW]
Upvotes: 0
Views: 720
Reputation: 2534
updated
hook is related to changes in the DOM, if this state is not updating the DOM you won't see updated
being called.
From https://v2.vuejs.org/v2/guide/instance.html#Lifecycle-Diagram:
Upvotes: 1