2

This is not a questions itself, but a good issue to Vue community. I want to open a discussion about Vuex and immutability. When we enable Vuex strict mode and when we have within the state an object called by a computed function that we need to change its properties into a component, we are warned not to take this practice. Ok, this is not new...

I got the point of it and I am convinced that it is for the best, but I find myself having to clone (deep clone) the object into a computed/data in order to be able to work with a local state without mutante it directly.

So I have a question: since it is not a good practice to mutate the properties of an object directly and since I have to use this.$store.commit / this.$store.disptach to mutante the state, why Vuex does not deliver a deep clone of this object instead of a shallow clone when we call the state by this.$store.state or this.$store.getters within a computed.

vue-freeze is a module that tries to react to this issue, but it is not update since a long time. How do you folks work with this?

calebeaires
  • 1,972
  • 1
  • 22
  • 34

0 Answers0