Open Simon-Renault opened 4 years ago
@Simon-Renault Yes, I have noticed that - I believe it is to do with the Vuex persisted plugin I am using: try removing that, and everything should work as expected. Not quite sure why it happens though, that needs more investigating.
In the most recent storefront-ui
branch I have actually replaced it...
I have a fix for that, simple but not super pretty. The issue does not seems to happen if you load the state after the initial render. So just triggering the store update directly after the first render should be fine. Using nextTick to retrieve and commit the saved state.
store.subscribe((mutation, state) => {
if(mutation.type === 'updateCart'){
localStorage.setItem("cart",JSON.stringify(state.cart))
}
})
and in the cart page/component
mounted(){
this.$nextTick(() => {
const cart = JSON.parse(localStorage.getItem("cart"))
if(cart){
this.$store.commit("updateCart",cart)
}
})
}
When you reload the page on the cart using the reload button or "cmd + r" the page experience some weird behaviours :
Two errors visible in the console :