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.

Updating a model via constructor causes a Vuex error

See original GitHub issue

As 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:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
NickBollescommented, Feb 28, 2019

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.

0reactions
marshallswaincommented, Sep 24, 2019

I’m going to close this since it’s fixed in the pre-release.

Read more comments on GitHub >

github_iconTop 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 >

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