f / vue-wait

Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
MIT License
2k stars 101 forks source link

Consider v-show instead of v-if for v-wait component #45

Open anorborg opened 6 years ago

anorborg commented 6 years ago

I noticed while I was uisng the v-wait component, my component that I was wrapping was being created twice. First on initial load, then again after my call to my API to load the data. Looking over the source and the vuejs docs I saw this:

https://vuejs.org/v2/guide/conditional.html#v-if-vs-v-show

Which states that:

"...child components inside the conditional block are properly destroyed and re-created during toggles"

I wonder if it would be better for v-wait to use v-show instead? Or add an option?

avinograd0v commented 6 years ago

I think more correct way is using v-if when v-wait first mounts, and then using v-show for future updates

Another way is to add option for v-wait (something like v-once) to trigger conditional render only once for waiter with specific name