vuejs / vuex-router-sync

Effortlessly keep vue-router and vuex store in sync.
MIT License
2.52k stars 125 forks source link

fix: clone route outside of mutation #93

Closed cjpearson closed 2 months ago

cjpearson commented 5 years ago

This change moves to call to cloneRoute outside of the mutation and passes the already-cloned route as the payload. It fixes some console errors that might occur when the vue-devtools extension tries to clone the mutation payload. In my case there were errors when it attempted to clone components within the matched array of the route.

kiaking commented 4 years ago

Hi thanks for the PR and sorry for the late response. Could you provide the reproduction code for this?

kiaking commented 4 years ago

Closing due to inactivity.

cjpearson commented 4 years ago

@kiaking Sorry for the late reply. I've created a demo here. Basically anything that attempts to log or persist mutations can be tripped up by the payload of the ROUTE_CHANGE mutations.

The simplest way to create an error is with a mutation logger which attempts to stringify the payload.

If you attach vue-devtools to the page and enable the new vuex backend, you'll also get errors there as it attempts to clone the mutation. The cloning logic there is different and it doesn't always throw an error when cloning a component.

kiaking commented 4 years ago

@cjpearson Ah, thank you so much for checking in. OK now I see the problem here. Would it be possible for you add a test for this?

cjpearson commented 4 years ago

Yeah I can take a crack at that.

kiaking commented 4 years ago

@cjpearson Thanks a lot! In that case, please rebase the branch to the latest master branch. Now we're writing everything in TS 👍