According to the Official docs, vuex mutations has some limitation in reactivity.
When adding a new property to an object we have to do,
Vue.set(obj, 'newProp', 123)
This is fine. But how do we add new array property and push elements to that without breaking the reactivity?
This is what I have done up to now. This is working fine but the problem is this is not reactive. Getters can't recognize the changes happen to the state.
set_add_ons(state, payload) {
try {
if (!state.tour_plan[state.tour_plan.length - 1].add_ons) {
state.tour_plan[state.tour_plan.length - 1].add_ons = [];
}
state.tour_plan[state.tour_plan.length - 1].add_ons.push(payload);
} catch (error) {
console.log("ERR", error)
}
},
How do I convert this to a code which is reactive?