Skip to content
Advertisement

“Do not mutate vuex store state outside mutation handlers” error even after using computed var for prop

With the following component, I am getting an Error: [vuex] do not mutate vuex store state outside mutation handlers. error:

JavaScript

For reference, here is headers.js:

JavaScript

and BaseTableColumn.vue:

JavaScript

The issue happens here:

JavaScript

However, if I follow the docs like so:

JavaScript

I still get the errors, specifically in the updated() hook and the highlightFirst() method, even though I’m not referencing or mutating a prop. What else do I need to change to get rid of this error?

Advertisement

Answer

The way I eventually solved this problem was to emit an event and use the row value in the parent component:

JavaScript

However, to @Jesper’s point above, since then, I have been using Object.assign() in cases like this where I need to break the link to Vuex.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement