diff --git a/README.md b/README.md index c114e78..05bcad8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ sync(store, router) // done. - When the router navigates to a new route, the store's state is updated. -- When the store's `route` state is updated, it notifies the router to navigate to the corresponding path. This enables time-traveling between routes in `vue-devtools`. +- **`store.state.route` is immutable, because it is derived state from the URL, which is the source of truth**. You should not attempt to trigger navigations by mutating the route object. Instead, just call `$router.go()`. ### License diff --git a/index.js b/index.js index 5fbee38..3361310 100644 --- a/index.js +++ b/index.js @@ -49,16 +49,7 @@ function patchStore (store) { route: { mutations: { 'router/ROUTE_CHANGED': function (state, to) { - Object.keys(to).forEach(key => { - if (key !== 'matched') { - set(state, key, to[key]) - } - }) - Object.keys(state).forEach(key => { - if (!(key in to)) { - state[key] = null - } - }) + store.state.route = to } } }