DEV Community

Discussion on: Watch for Vuex State changes!

Collapse
 
eladc profile image
Elad Cohen

Why you use Vue.set(state, 'status', status) instead of just state.status = status?

Collapse
 
viniciuskneves profile image
Vinicius Kiatkoski Neves

In this case it is not necessary and I could have use state.status = status, no worries.

But as I'm more concerned with (vuejs.org/v2/guide/reactivity.html) I've got used to always write Vue.set to avoid any pitfalls while developing. So it is just a way to keep the codebase concise (in one mutation it is state.prop = prop and in the other is Vue.set...).