Enabling strict mode while developing

When Vuex is in strict mode, it will throw an error if the single state tree is mutated outside mutation handlers. This is useful when developing to prevent accidental modifications to the state. To enable strict mode, you just need to add strict: true to the store configuration object:

const store = new Vuex.Store({  // ...  strict: true});

Strict mode should not be used in production. Strict mode runs a synchronous deep watcher on the state tree for detecting inappropriate mutations, and this can slow down the application. To avoid changing strict to false each time you want to create a production bundle, you should use a build tool that makes the strict value false when creating the production bundle. ...

Get Vuex Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.