Describe the bug
I have a question: has anyone else encountered a situation where eslint does not show the error mentioned in this link? https://tanstack.com/query/v5/docs/eslint/no-unstable-deps#rule-details
If mutation and the use of mutate are in different files, then when I use mutation.mutate in deps, no error is displayed, but if they were in the same file, an error would be displayed.
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-peqt34c7?file=src%2Findex.tsx
Steps to reproduce
// File 1
export const useMutation = () => {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (payload: string[]) => update(payload),
onMutate: async () => {
await queryClient.cancelQueries({ queryKey: 'test' })
const previousTest = queryClient.getQueryData('test')
return { previousTest }
},
onSuccess: (data) => {
queryClient.setQueryData('test', (old: ExampleType[]) =>
old.map((test) => (test._id === data._id ? data : test))
)
},
onError: (_err, _var, context) => {
queryClient.setQueryData('test', context?.previousTest)
},
})
}
// File 2
const mutation = useMutation()
const handleUpdate = useCallback(
(changedItems: ExampleType[]) => {
const orderedIds = changedItems.map((item) => item._id)
mutation.mutate(orderedIds)
},
[mutation] // Should give an warning that mutation is not stable
)
Expected behavior
Should report warn when using mutation in deps
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Windows
- Browser: Chrome
- Version: 139.0.7258.128
Tanstack Query adapter
react-query
TanStack Query version
v5.90.2
TypeScript version
v5.9.3
Additional context
No response
Describe the bug
I have a question: has anyone else encountered a situation where eslint does not show the error mentioned in this link? https://tanstack.com/query/v5/docs/eslint/no-unstable-deps#rule-details
If mutation and the use of mutate are in different files, then when I use mutation.mutate in deps, no error is displayed, but if they were in the same file, an error would be displayed.
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-peqt34c7?file=src%2Findex.tsx
Steps to reproduce
Expected behavior
Should report warn when using mutation in deps
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Tanstack Query adapter
react-query
TanStack Query version
v5.90.2
TypeScript version
v5.9.3
Additional context
No response