Describe the bug#
I have a useQuery hook from my router , and I'm passing the result of that into a useCallback, and the no-unstable-deps rule is flagging it as unstable, even though it's not.
eg:
import { useQuery } from './router';
function SomeComponent() {
const query = useQuery();
const onChange = useCallback((selection: string) => {
setRoute({
query: {
...query,
selection,
},
})
}, [query])
return <></>
}
Your minimal, reproducible example#
https://codesandbox.io/p/sandbox/elated-sun-nh3m34 (worth noting, I couldn't get eslint working in CSB, so it's just a code reference)
Steps to reproduce#
- Have an existing
useQuery hook that is not from Tanstack query
- Use the return value of that hook as a dependency in a hook that has a dependency array (useEffect, useMemo, useCallback, etc)
Expected behavior#
As a user, I would not expect an error here, since the return value of my hook may be referentially stable. Errors should only show up if the useQuery is imported form Tanstack query.
How often does this bug happen?#
Every time
Screenshots or Videos#
No response
Platform#
N/A
- @tanstack/eslint-plugin-query: 5.91.2
- eslint: 9.32.0
Tanstack Query adapter#
react-query
TanStack Query version#
v5.90.2
TypeScript version#
v5.4.5
Additional context#
No response
I think we only check the name @Newbie012 ?
https://github.com/TanStack/query/blob/9595254b2fc1446f1ed3d69f2ec9197f7165befe/packages/eslint-plugin-query/src/rules/no-unstable-deps/no-unstable-deps.rule.ts#L10-L17