You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The template ref watcher should be called once the mounted hook is finished.
What is actually happening?
The template ref watcher gets called immediately, so that data assigned in the mounted hook are not called yet and accessing public methods/properties are still undefined.
See the setup in InfiniteLoaderWrapper.vue. Using @vue/composition-api and vue ^2.6 the watcher would be called when the mounted hook is finished. With vue ^2.7 the watcher of the template ref is called immediately upon instantiation, so that vm.stateChanger is still undefined!
setup(_,{ emit }){constinfiniteLoader=ref(null)onMounted(()=>{// prints objectconsole.log(infiniteLoader.value.stateChanger);})constunwatch=watch(infiniteLoader,(vm: any)=>{// prints undefinedconsole.log(vm.stateChanger);if(!vm)returnemit('infinite',vm.stateChanger)unwatch()})return{
infiniteLoader,}}
The text was updated successfully, but these errors were encountered:
johannes-z
changed the title
Template ref watcher triggers before mounted is finished
Component template ref watcher triggers before its mounted hook is finished
Jun 23, 2022
Version
2.7.0-beta.5
Reproduction link
github.com/johannes-z/vue27
Steps to reproduce
What is expected?
The template ref watcher should be called once the
mounted
hook is finished.What is actually happening?
The template ref watcher gets called immediately, so that data assigned in the
mounted
hook are not called yet and accessing public methods/properties are stillundefined
.See the
setup
inInfiniteLoaderWrapper.vue
. Using@vue/composition-api
and vue^2.6
the watcher would be called when themounted
hook is finished. With vue^2.7
the watcher of the template ref is called immediately upon instantiation, so thatvm.stateChanger
is still undefined!This is how the property gets assigned in the library component I'm using: https://github.com/PeachScript/vue-infinite-loading/blob/master/src/components/InfiniteLoading.vue#L218
The text was updated successfully, but these errors were encountered: