How to use tanstak queryClient (or queries/mutations) in Vue custom directives? #5769
Unanswered
viktorkrepak
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Perhaps this PR #5703 could solve your issue, but currently, there are still some limitations, and it needs to wait for Vue's PR vuejs/core#8801 to be completed before it can be implemented. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! I've been using Tanstack with my Vue3 application and it works awesome, but I've got stuck with one tricky issue.
I wanted to create a
hasRole
directive to check a user roles and based on the input value (array of acceptable roles) make a decision whether I can render a component for this user or no.I'm fetching the user data using a query and It's saved in my the tanstack cache and I don't want to duplicate this data to Pinia store, but when I try to use Tanstack queryClient inside of my custom directive I get this error
Error: vue-query hooks can only be used inside setup() function.
. So to temporary fix that I've passed the user data using directive input parameters, but It looks like a dirty solution. Can smb help me with the issue? Can I somehow use the queryClient in Vue custom directives?Beta Was this translation helpful? Give feedback.
All reactions