1

This will result in false on the mounted hook.

But it's set to true and will also return true on a method as expected, or computed property or directly even on a v-if="" statement!

this.$store.getters.getIsLoggedIn

I'd like to use the state to perform action upon mounting the component, but am I to presume that for some reason the state is not readable at this stage? What am I not understanding about Vuex?

4
  • 2
    this might not be enough context to answer the question Commented Sep 7, 2018 at 19:08
  • could you provide the main.js ? Commented Sep 7, 2018 at 19:10
  • The Vuex state is readable in the mounted hook. At which times are you observing it's value is true – outside of the mounted hook? It could be initially false (during mounted) but then changed to true after mounting. You need to carefully debug it at different stages of the component lifecycle to confirm its value is what you expect at that time. We can't help you much beyond guessing what the issue could be without a MCVE. Commented Sep 8, 2018 at 1:58
  • Sorry there's no example here, it's quite complicated and is a Laravel user object that's setting the variable in this manner - stackoverflow.com/questions/51329297/… So, it is a debugging issue I think. It's good to have confirmation that the Vuex state is readable in the mounted hook which helps narrow down. Commented Sep 10, 2018 at 14:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.