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

Unknown mutation type: updateCanUndoRedo #74

Open
tobiascornille opened this issue Jul 6, 2021 · 2 comments
Open

Unknown mutation type: updateCanUndoRedo #74

tobiascornille opened this issue Jul 6, 2021 · 2 comments

Comments

@tobiascornille
Copy link

tobiascornille commented Jul 6, 2021

I'm using a non-namespaced (basic) vuex store and when I commit a change, I'm getting the following error:
(to be more precise: the error is logged twice)

[vuex] unknown mutation type: updateCanUndoRedo
commit @ vuex.esm.js?2f62:460
boundCommit @ vuex.esm.js?2f62:409
eval @ undo-redo-vuex.esm.min.js?53f4:1
eval @ undo-redo-vuex.esm.min.js?53f4:1
eval @ vuex.esm.js?2f62:472
commit @ vuex.esm.js?2f62:472
boundCommit @ vuex.esm.js?2f62:409
handleSelectTool @ Toolbar.vue?9799:66
click @ Toolbar.vue?4fa2:12
invokeWithErrorHandling @ vue.runtime.esm.js?2b0e:1854
invoker @ vue.runtime.esm.js?2b0e:2179
original._wrapper @ vue.runtime.esm.js?2b0e:6917

Any clue what I'm missing or doing wrong?

@tobiascornille
Copy link
Author

I think the documentation is incorrect. When initializing the store as below I get the error.

import Vuex from "vuex";
import undoRedo from "undo-redo-vuex";

export default new Vuex.Store({
  state,
  getters,
  actions,
  mutations,
  plugins: [
    undoRedo({
      // NB: Include 'ignoreMutations' at root level, and do not provide the list of 'paths'.
      ignoreMutations: ["addShadow", "removeShadow"],
    }),
  ],
});

However, in the demo scaffoldStore is also added. If I add that, then the plug-in works as expected.

export default new Vuex.Store(
    scaffoldStore({
        state,
        actions,
        mutations,
        plugins: [
            undoRedo()
        ]
    })
);

@andrewbeng89
Copy link
Member

Hi @tobiascornille thanks again for this well spotted gap in the documentation! 👍

The observation is indeed correct, the scaffoldStore function serves as a wrapper to add "boilerplate" to the state, actions and mutations of the store.

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

2 participants