vuejs / vuex

🗃️ Centralized State Management for Vue.js.
https://vuex.vuejs.org
MIT License
28.42k stars 9.58k forks source link

vux get states #2165

Closed sara-farokhi closed 2 years ago

sara-farokhi commented 2 years ago

I am a junior vuejs front-end developer. I use vue3 and composition api (version: "^3.2.33") using vueX state management (version: "^4.0.2"). As you know we should use the computed callback function to get data from vuex state, then return the data in the setup function to use it in the template. The problem is that I need the value of the computed callback function to get data from vuex state BEFORE ITS FIRST RENDERING through setup return. The first time it returns the default value which is defined in the vueX ALTHOUGH THERE IS A DISPATCH TO CHANGE ITS STATE value. when there is a dispatch in the setup the value is the default value taken from the vuex, and the value is not updated before setup return. Is there any solution to get the value of the computed callback function which returns a from vuex state before its first rendering in the setup? I need the value before returning from the setup, is there any solution? by the way, I tried to get the value in the unMounted in the setup function and mounded outside of setUp but there was not any solution.

vue-bot commented 2 years ago

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

phil294 commented 2 years ago

@sara-farokhi perhaps you are missing an await before your dispatch? If not, I'd suggest you create a question on StackOverflow where you would supply the relevant code snippet. It's hard to help you without seeing any code :D

cuebit commented 2 years ago

Alternatively, head over to the forum or Discord chat to get hands-on help. 👍