Skip to content

"Do not mutate store state outside mutation handler" error but I am using a mutation #1151

@davewood

Description

@davewood

Version

3.0.1

https://github.com/davewood/vuejs-demo/tree/vuex_mutation_error

Steps to reproduce

git clone -b vuex_mutation_error git@github.com:davewood/vuejs-demo.git
cd vuejs-demo
npm install
npm run dev
trigger error in console by changing the language in top right corner

What is expected?

the state is changed and a notification is shown as expected but i dont get an error in the console

details:

  • store has an array of notifications
  • notifications are added using a mutation in src/store.js
  • global Vue handler to trigger notification is installed in src/notify.js

What is actually happening?

the code works but there is an error in the console


[Vue warn]: Error in callback for watcher "function () { return this._data.$$state }": "Error: [vuex] Do not mutate vuex store state outside mutation handlers."

(found in <Root>) 9:579:7
warn webpack-internal:///9:579:7
logError webpack-internal:///9:1714:5
globalHandleError webpack-internal:///9:1709:3
handleError webpack-internal:///9:1698:3
run webpack-internal:///9:3209:11
update webpack-internal:///9:3181:5
notify webpack-internal:///9:685:5
mutator webpack-internal:///9:843:5
add_notification/< webpack-internal:///116:21:9
Error: [vuex] Do not mutate vuex store state outside mutation handlers.
Stack trace:
assert@webpack-internal:///50:104:27
enableStrictMode/<@webpack-internal:///50:753:7
run@webpack-internal:///9:3207:11
update@webpack-internal:///9:3181:5
notify@webpack-internal:///9:685:5
mutator@webpack-internal:///9:843:5
add_notification/<@webpack-internal:///116:21:9
9:1718:5
logError webpack-internal:///9:1718:5
globalHandleError webpack-internal:///9:1709:3
handleError webpack-internal:///9:1698:3
run webpack-internal:///9:3209:11
update webpack-internal:///9:3181:5
notify webpack-internal:///9:685:5
mutator webpack-internal:///9:843:5
add_notification/< webpack-internal:///116:21:9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions