Feature request: Allow some variable names from @tanstack/query/exhaustive-deps #7276
-
|
I normally create custom hooks that return queries that depends on other values, like an authentication token. I use the authentication token in queryFn but then the eslint rule @tanstack/query/exhaustive-deps requires the token to be in the query key, which is not good once authentication tokens are not supposed to be part of a query key. It would be good to configure the rule with a list of allowed names to not require them in the queryKey, like |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
|
if your code looks like this: then the rule is technically correct because you are closing over The real question is: Why is but ideally, all of this would live outside of react ... |
Beta Was this translation helpful? Give feedback.
-
|
I think this is addressed by #10295 ? |
Beta Was this translation helpful? Give feedback.
-
|
We also have a usecase for this: We manage our http environment with react providers. e.g. for dynamic auth szenarios After the latest tanstack query update we got a list with >100 warnings. |
Beta Was this translation helpful? Give feedback.
-
|
allowlist -> types seems to have a very strange behaviour. Only works for around 70% of cases. I can not figure out why. For example: httpClient is of type AxiosInstance. Strange thing is: It works on other places that seems to be completely the same use case. I dont know how this works internally. But I can not provide real types, only type names as strings. And my IDE references the string type name to a wrong, deprecated type for Keycloak. Probably is has to do with something like this... |
Beta Was this translation helpful? Give feedback.
I think this is addressed by #10295 ?