[vuex] do not mutate vuex store state outside mutation handlers
See original GitHub issueSteps 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:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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