Akryum / Akryum/vue-cli-plugin-ssr

Vuex strict mode always leads to "do not mutate vuex store state outside mutation handlers"

Abierto
#184 2 comentarios 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
441
Forks
69
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Strict mode: https://vuex.vuejs.org/guide/strict.html

When this is enabled, all mutations throw an error (stack trace below), *even when commited* through a mutation, as you should:
```html
set someVal
```
```js
export function createStore() {
return new Vuex.Store({
strict: true, // <----------
state() { return { someVal: false } },
mutations: {
setSomeVal(state) {
state.someVal = true;
}
},
actions: {}, modules: {}
})}
```
Clicking the button should not generate the error, but it does. I tested this with a clean vue project with nothing else added.

Is this expected behaviour or a bug? If the latter, do you still accept pull requests in case I can track it down?
Thanks!

```
VM547 chunk-vendors.js:8373 [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 )
warn @ VM547 chunk-vendors.js:8373
logError @ VM547 chunk-vendors.js:9636
globalHandleError @ VM547 chunk-vendors.js:9631
handleError @ VM547 chunk-vendors.js:9591
run @ VM547 chunk-vendors.js:12317
update @ VM547 chunk-vendors.js:12289
notify @ VM547 chunk-vendors.js:8484
reactiveSetter @ VM547 chunk-vendors.js:8809
reactiveSetter @ vue.runtime.esm.js:1050
setSomeVal @ index.js:16
wrappedMutationHandler @ vuex.esm.js:744
commitIterator @ vuex.esm.js:392
(anonymous) @ vuex.esm.js:391
_withCommit @ vuex.esm.js:526
commit @ vuex.esm.js:390
boundCommit @ vuex.esm.js:335
click @ Home.vue?012f:17
invokeWithErrorHandling @ vue.runtime.esm.js:1854
invoker @ vue.runtime.esm.js:2179
original._wrapper @ vue.runtime.esm.js:6917
VM547 chunk-vendors.js:9640 Error: [vuex] do not mutate vuex store state outside mutation handlers.
at assert (VM547 chunk-vendors.js:16303)
at Vue.store._vm.$watch.deep (VM547 chunk-vendors.js:17006)
at Watcher.run (VM547 chunk-vendors.js:12315)
at Watcher.update (VM547 chunk-vendors.js:12289)
at Dep.notify (VM547 chunk-vendors.js:8484)
at Object.reactiveSetter (VM547 chunk-vendors.js:8809)
at Object.reactiveSetter [as someVal] (VM547 chunk-vendors.js:8804)
at Store.setSomeVal (VM548 app.js:1950)
at wrappedMutationHandler (VM547 chunk-vendors.js:16957)
at commitIterator (VM547 chunk-vendors.js:16605)
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.