E
E
eugenedrvnk2020-08-07 18:26:48
Vue.js
eugenedrvnk, 2020-08-07 18:26:48

What is the risk of updating the state of the store not through mutations?

The vue documentation says that the only way to change the state is through mutations, and this is what I used during the entire time I worked with 'vue'.
But somehow I suddenly realized that the store can be easily changed simply by referring to the store object, for example this.$store.state.x = 1 and still it works fine.
I tried to find answers in the direction of what could break when changing the state directly - I did not meet any specifics. Basically everything refers to the vue documentation without further information. What is it all the same fraught with? Because the only negative that I see is the lack of logging of mutations in the vuex devtoolz)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-08-07
@eugenedrvnk

At least all plugins will fall off. https://vuex.vuejs.org/en/guide/plugins.html
Well, there may be more hidden side effects. In order to track an accidental change, there is a strict mode. https://vuex.vuejs.org/ru/guide/strict.html
If it seems that vuex is too complicated, then nothing prevents you from using one or more shared stores in the root component https://ru.vuejs.org/v2/ guide/state-management.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question