Updating a model via constructor causes a Vuex error
See original GitHub issueAs of v1.7.0, creating a new record in the store works fine like so:
new $nuxt.$FeathersVuex.User({
"id": "doug",
"name": "Doug Bowser",
});
A new record is added to the store, reactivity seems to work fine. Calling the constructor with exact same data again also causes no errors. However, calling the constructor with an existing id and modified data causes a Vuex error:
new $nuxt.$FeathersVuex.User({
"id": "doug",
"name": "Doug Bowsette",
});
vue.runtime.esm.js:1887 Error: [vuex] do not mutate vuex store state outside mutation handlers.
at assert (vuex.esm.js:87)
at Vue.store._vm.$watch.deep (vuex.esm.js:763)
at Watcher.run (vue.runtime.esm.js:4529)
at Watcher.update (vue.runtime.esm.js:4503)
at Dep.notify (vue.runtime.esm.js:730)
at FeathersVuexModel.reactiveSetter [as some] (vue.runtime.esm.js:1055)
at utils.js:276
at Array.forEach (<anonymous>)
at updateOriginal (utils.js:250)
at new FeathersVuexModel (model.js:44)
Using store.dispatch('orders/addOrUpdate', newRecord)
does not have the same issue, however.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Vuex Not Updating Component - typescript - Stack Overflow
I am building a site with Vue and Vuex in TypeScript. (Sorry for the long code examples). I have a Store Module ('musicArtists'):...
Read more >Why Your Vue Component Isn't Updating (and how to fix it)
1. Check that variables are reactive · You're updating a variable somewhere in your component, but your component isn't updating · You are...
Read more >How to unit test a Vuex store - Dev tips and tricks
So a unit test would call a mutation with a fake state object and assert that the object is updated. In the example...
Read more >Guides | Vue Test Utils
Vue Test Utils (VTU) is a set of utility functions aimed to simplify testing Vue.js components. It provides some methods to mount and...
Read more >Models and Collections for Vue.js - Vue Models & Collections
The default constructor for a model accepts three optional parameters: attributes , collection ... the errors property of the model would then be...
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 Free
Top 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
Both are related to getting records from the Vuex store.
In both cases, calling New on a record not on the store works fine. But the second time (with an ID) it doesn’t. But my particular case was because of the SSR store. Although I ran across the same issue you are describing too.
Similar reproduction steps, not the same issue. But it’s worth linking the issues together IMO.
I’m going to close this since it’s fixed in the pre-release.