[Vuejs]-Vuex commit fires too fast

0👍

Since this was a while ago I am not 100% sure how I fixed this but I think it was by using $nextTick from Vue.js.

By waiting on nextTick you ensure that your call stack for DOM updates has been cleared. This prevents DOM updates that might rely on other parts of your DOM from firing too fast.

Obviously this is way more reliable than simply setting a setTimeout with a given number of let’s say 100 milliseconds from my example because if your DOM does not update in time it might still pass this window.

If setTimeout fixed your issue I suggest trying $nextTick.

https://v2.vuejs.org/v2/api/#Vue-nextTick

Leave a comment