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
Create a new project with the vue create command, select vuex, create a new variable {} in the state of vuex, and return a variable associated with this variable in the getters. This variable is obtained by computed in a concrete page. Under this variable it is fine if it is printed, but it is undefined if it is printed in onUnmounted
What is expected?
data from Vuex obtained through Computed can be correctly retrieved during onUnmounted
What is actually happening?
The data in Vuex obtained through computed onUnmounted is undefined
The text was updated successfully, but these errors were encountered:
dengyizhenfeng
changed the title
Data from Vuex was not available in the Onunmounted
The data obtained through Computed vuex is undefined in onUnmounted
Jan 22, 2021
Nice catch. I've confirmed. But this happens with Vue's plain reactive as well.
import{reactive,computed,onUnmounted}from'vue'exportdefault{setup(){constobj=reactive({})constcomputedObj=computed(()=>obj)// If we comment out this, then the `computedObj` becomes `undefined`// inside `onUnmounted` hook.console.log(computedObj.value)onUnmounted(()=>{console.log(computedObj.value)})}}
so not Vuex problem. Couldn't find existing issue for this 🤔 Probably would close this issue here, but I'm checking if there's any existing one, or if not, we should create an issue at Vue repo. Until then, I'll keep this one open!
Version
4.0.0-rc.2
Reproduction link
https://github.com/dengyizhenfeng/vue3-getters-undefined
Steps to reproduce
Create a new project with the
vue create
command, selectvuex
, create a new variable {} in the state of vuex, and return a variable associated with this variable in the getters. This variable is obtained by computed in a concrete page. Under this variable it is fine if it is printed, but it is undefined if it is printed in onUnmountedWhat is expected?
data from Vuex obtained through Computed can be correctly retrieved during onUnmounted
What is actually happening?
The data in Vuex obtained through computed onUnmounted is undefined
The text was updated successfully, but these errors were encountered: