Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: [vuex] state field "route" was overridden by a module with the same name at "route" #101

Open
Unkrass opened this issue Apr 15, 2021 · 3 comments

Comments

@Unkrass
Copy link

Unkrass commented Apr 15, 2021

I use the following packages:

"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0",
"vuex-persistedstate": "^4.0.0-beta.3",
"vuex-router-sync": "^6.0.0-rc.1"

When I reload a page - and I believe it only happens when the state i persisted - I get the warning message

[vuex] state field "route" was overridden by a module with the same name at "route"

In my opinion this shouldn't be happening, because I didn't define any modules in my store. changing the module name to e.g. "RouteModule" as written in the docs throws the same warning, except then with "RouteModule" instead of "route".

Is there a way to fix this?

@denizderman
Copy link

Is vuex-router-sync going to support vue3? I believe this issue is related to that, but I might be wrong.

@mylemans
Copy link

mylemans commented Feb 8, 2022

Is vuex-router-sync going to support vue3? I believe this issue is related to that, but I might be wrong.

FYI: I'm having this issue on vue2
edit: Seem to trigger (or can trigger) during 'time travel', so for me I can ignore the issue, but I rather would not see that warning ofc

@jremi
Copy link

jremi commented May 4, 2022

@Unkrass what you can do...

When you invoke the vuex-persistedstate plugin...

e.g:

import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex);

export default new Vuex.Store({
  plugins: [
    createPersistedState({
      // This omits the plugins/vue-router-sync state.route from persisting
      paths: ["foo", "bar", "zee"],
    }),
  ],
  state: {
    foo: {},
    bar: {},
    zee: {}
  }
});

The above is a simple contrived example... But what is important is passing to the createPersistedState options the paths and explicitly only setting the paths that are in the vuex state. When you do this the vuex-persistedstate plugin won't persist the automatically added state.route that vuex-router-sync injects.

This will make the warning not appear.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants