-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eslint exhaustive-deps incorrectly labelling constant value as key dependency #5196
Comments
can confirm, here is a failing test case:
@Newbie012 FYI |
Hopefully I'll have the time today to fix this and the other issue. |
Should be fixed once #5217 is merged. |
@TkDodo @Newbie012 the new update fixes this issue when the
const T = 1;
// No error
function test() {
useQuery({
queryKey: ['foo'],
queryFn: () => T,
});
}
// Errors
const test = () => {
useQuery({
queryKey: ['foo'],
queryFn: () => T,
});
}
// also errors
const useTest2 = function () {
useQuery({
queryKey: ['foo'],
queryFn: () => T,
});
}; |
@TkDodo @Newbie012 Just saw its supposed to be fixed by the latest release (4.29.8), however I'm still experiencing this error when using an external function to define the query: const Ab = 1
// This throws the error
function groupsQuery() {
return {
queryKey: ['get-groups'],
queryFn: () => Ab,
}
}
// This works
function useGroups() {
return useQuery({
queryKey: ['get-groups'],
queryFn: () => Ab,
})
} |
please create a new issue for this @luizeboli |
Describe the bug
@tanstack/[email protected]
incorrect exhaustive-deps error for constant values when using them in the queryFn
Steps to reproduce
use a constant in the
queryFn
property for auseQuery
hook. then you will see an error saying that the constant is not in the dependency arrayExpected behavior
constants should not count as a dependency
Platform
vscode
Tanstack Query adapter
react-query
TanStack Query version
4.27.0
The text was updated successfully, but these errors were encountered: