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:
- An existing reactive object/array.
- A property/index that you want to add and be reactive.
- The value of the new property/index.
Try changing
Vue.set(state.myData[index], "foo", data);
to
Vue.set(state.myData, index, {"foo": data});