[Vuejs]-Uncaught TypeError when pushing to an array in the Vuex store's state

0๐Ÿ‘

I had initially installed Vuex with npm install vuex@4.0.0-beta.4, but I should have done npm install vuex@next. After installing it properly, the error went away.

-1๐Ÿ‘

Try to use Spread syntax like in VUEX Documentation:

const state = {
  flash: []
};

const mutations = {
  PUSH_FLASH(state, payload) {
    state.flash = [...state.flash, payload]
  }
};

Leave a comment