1

Not quite sure if this is a post for stackoverflow but i really struggle with this one.

I'm using vuex and vue1. I love vuex because you can't/shouldn't change the store without mutations.

But now I'm passing a state object to a (child) component. When I'm changing the value in the child component. Vuex allows me to change it.

Is there a specific reason why this can be done or is this just bad practice?

Parent component

<child-component :pass-value="stateValueParent"> </child-component>

vuex: {
        getters: {
            stateValueParent: (state) => state.values.stateValueParent
        }
}

Child component

 export default {
        props: [
            'passValue'
        ],

let value = this.passValue

// This is changed but it should right?
value = 'newValue'
  • I don't quite understand your question but believe that the state is changing because it's being passed by reference (and not value) to the child element. http://stackoverflow.com/a/6605700/3512709 – Adam Mar 29 '17 at 16:02
  • did you try using vuex in `strict` mode? – Srinivas Damam Mar 29 '17 at 17:41

0 Answers0