-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
Describe the bug
follow up on #5196
pr #5217 fixed constant values being labelled as dependencies within regular functions only.
however, this did not fix the same issue for arrow functions. see example below:
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,
});
};Your minimal, reproducible example
see above
Steps to reproduce
new test below:
{
name: 'should ignore constants defined out of arrow function scope',
code: `
const CONST_VAL = 1
const MyComponent = () => {
useQuery({
queryKey: ["foo"],
queryFn: () => CONST_VAL
});
}
`,
},
Expected behavior
constants should not count as a dependency and exhaustive-deps should be consistent across different function declarations
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
vscode
Tanstack Query adapter
None
TanStack Query version
v4.29.4
TypeScript version
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels