Vuex & Storybook: Cannot set reactive property on undefined, null, or primitive value: undefined Vuex & Storybook: Cannot set reactive property on undefined, null, or primitive value: undefined vue.js vue.js

Vuex & Storybook: Cannot set reactive property on undefined, null, or primitive value: undefined


I found some issues in the component and store on GitHub. After correcting them I was able to run it without errors.

Firstly, there is no data-index attribute on the <input>. Once this is added, it must be parsed to an integer so it can be used as an array index in the store mutation.

Secondly, the use of Vue.set() is incorrect. The expected arguments are:

  1. An existing reactive object/array.
  2. A property/index that you want to add and be reactive.
  3. The value of the new property/index.

Try changing

Vue.set(state.myData[index], "foo", data);

to

Vue.set(state.myData, index, {"foo": data});

https://vuejs.org/v2/api/#Vue-set


Shouldn't you be using dispatch instead of Vue.set in Vuex? (storeModule.js)