question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[vuex] do not mutate vuex store state outside mutation handlers

See original GitHub issue

Steps to reproduce

Create chat app in nuxt by following these steps.

Below if code of file in which i am facing the issue.

<template>
  <form class="flex flex-row flex-space-between" @submit.prevent="onSubmit">
    <input v-model="message.text" type="text" class="flex flex-1" />
    <button class="button-primary" type="submit">Send</button>
  </form>
</template>

<script>
import { ref } from '@vue/composition-api'
export default {
  name: 'MessageComposer',
  setup(props, context) {
    const { Message } = context.root.$FeathersVuex.api;
    const message = ref(new Message({ text: '' }));
    function reset() {
      message.value = new Message({ text: '' });
    }
    function onSubmit() {
      if (!message.value.text) { return; };
      message.value.save();
      reset();
    }

    return { message, reset, onSubmit }
  }
}
</script>

Expected behavior

It should work without any errors in strict mode too.

Actual behavior

It gives this error on v-model change.

For resolving this error i had to add export const strict = false in services/index.js

I am using suggested syntax in nuxt-full-example instead of exporting vuex store.

System configuration

feathers-vuex: 3.6.1 @vue/composition-api: 0.3.4 vuex: 3.1.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tkssharmacommented, Apr 17, 2021

vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in callback for watcher "function () { return this._data.$$state }": "Error: [vuex] do not mutate vuex store state outside mutation handlers."

----- LONG STACK TRACE ----- could have been helpful if i know which store property is creating this issue

1reaction
itoonxcommented, Mar 2, 2020

The problem is your store/index.js It should be like this, Please check if you’re using createStore may be is deprecated in this version

export const state = () => ({
})

export const mutations = {
}

export const actions = {
}

export const getters = {}

export const plugins = [
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vuex - Do not mutate vuex store state outside mutation handlers
Error [vuex] Do not mutate vuex store state outside mutation handlers. What does it mean? It happens when I try to type in...
Read more >
Error: form binding with Vuex - Do not mutate vuex store state ...
The problem I'm seeing is that as soon as the a bound form field changes, it triggers the error: Do not mutate vuex...
Read more >
Vuex - Do not mutate vuex store state outside mutation handlers
Vuex - Do not mutate vuex store state outside mutation handlers ; width: 258px; height ; 258px; position: absolute; left ; 50%; top:...
Read more >
Resolve "do not mutate vuex store state outside ... - GitLab
After enabling Vuex's strict mode in !918 (merged), a number of "do not mutate vuex store state outside mutation handlers" warnings started showing...
Read more >
[vuex] Do not mutate vuex store state outside mutation handlers.
I am trying to get the top 5 products in the product array but this code which I am trying to access the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found