$q is undefined when used in store that's accessed in router navigation guard #15962
Unanswered
Advistane
asked this question in
CLI - PWA mode
Replies: 1 comment
-
Referring to https://quasar.dev/quasar-plugins/dark#outside-of-a-vue-file: Instead of using Alternatively, you can move the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all, I know the title sounds like a lot so let me break it down a bit.
Quasar Version 2.6.0
I have a store named "user" that handles settings, login/logout, database (Firestore) updates, etc.
Part of these settings is dark mode.
So a quick overview is like so:
Now, I'd like updateDb() to be called any time the page is changed. To do so, I'm taking advantage of the
afterEach
navigation guard. That code looks like so:Now, this works fine. However, it completely breaks the dark mode functionality of my site with this in the console:
which is the setDarkMode() function from above.
I've also noticed this error in the console:
[Vue warn]: inject() can only be used inside setup() or functional components.
This error is caused by
const $q = useQuasar();
.Now, I've looked at the Quasar App Flow documentation and it looks like Quasar is initialized before anything else so I'm confused as to why $q (the Quasar instance) is coming is as undefined.
The setDarkMode() functionality works perfectly fine when the navigation guard isn't created so I know it has something to do with the userStore being initialized in the guard.
If anyone has any ideas I'd greatly appreciate it. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions