You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/eslint/exhaustive-deps.md
+9-19Lines changed: 9 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,10 @@ id: exhaustive-deps
3
3
title: Exhaustive dependencies for query keys
4
4
---
5
5
6
-
Query keys should be seen like a dependency array to your query function: Every variable that is used inside the queryFn should be added to the query key.
7
-
This makes sure that queries are cached independently and that queries are refetched automatically when the variables changes.
6
+
Query keys should contain the serializable values that identify the data returned by your queryFn.
7
+
This makes sure that queries are cached independently and that queries are refetched automatically when those values change.
8
+
9
+
Function call targets are not query key dependencies. For example, `fetchTodoById(todoId)` needs `todoId` in the query key, but not `fetchTodoById`. Values referenced inside nested callbacks are still dependencies, so `promise.then(() => todoId)` also needs `todoId` in the query key.
8
10
9
11
## Rule Details
10
12
@@ -29,7 +31,7 @@ Examples of **correct** code for this rule:
0 commit comments