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: README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ A big thanks to both [Draqula](https://github.com/vadimdemedes/draqula) for insp
85
85
<summary>How is this different from Zeit's SWR?</summary>
86
86
<br />
87
87
88
-
[Zeit's SWR](https://github.com/zeit/swr) is a great library, and is very similar is spirit and implementation to React Query with a few notable differences:
88
+
[Zeit's SWR](https://github.com/zeit/swr) is a great library, and is very similar in spirit and implementation to React Query with a few notable differences:
89
89
90
90
- Automatic Cache Garbage Collection - React Query handles automatic cache purging for inactive queries and garbage collection. This can mean a much smaller memory footprint for apps that consume a lot of data or data that is changing often in a single session
91
91
- No Default Data Fetcher Function - React Query does not ship with a default fetcher (but can easily be wrapped inside of a custom hook to achieve the same functionality)
@@ -558,7 +558,7 @@ Let's assume we are using the default `cacheTime` of **5 minutes** and the defau
558
558
559
559
- A new instance of `useQuery('todos', fetchTodos)` mounts.
560
560
- Since no other queries have been made with this query + variable combination, this query will show a hard loading state and make a network request to fetch the data.
561
-
- It will then cache the data using `'todos'` and `` as the unique identifiers for that cache.
561
+
- It will then cache the data using `'todos'` and `fetchTodos` as the unique identifiers for that cache.
562
562
- A stale invalidation is scheduled using the `staleTime` option as a delay (defaults to `0`, or immediately).
563
563
- A second instance of `useQuery('todos', fetchTodos)` mounts elsewhere.
564
564
- Because this exact data exist in the cache from the first instance of this query, that data is immediately returned from the cache.
@@ -917,7 +917,7 @@ function Todo({ todoId }) {
917
917
}
918
918
```
919
919
920
-
Most of the time, this pattern works well, but if your source query you're using to look up the initial data from is old, you may not want to use the data at all and just fetch from the server. To make this decision easier, you can use the `queryCache.getQuery` method instead to get more information about the source query, including an `updatedAt` timestamp you can use to decide if the query is "fresh" enough for your needs:
920
+
Most of the time, this pattern works well, but if the source query you're using to look up the initial data from is old, you may not want to use the data at all and just fetch from the server. To make this decision easier, you can use the `queryCache.getQuery` method instead to get more information about the source query, including an `updatedAt` timestamp you can use to decide if the query is "fresh" enough for your needs:
921
921
922
922
```js
923
923
functionTodo({ todoId }) {
@@ -1125,7 +1125,7 @@ Even with just variables, mutations aren't all that special, but when used with
1125
1125
1126
1126
## Invalidate and Refetch Queries from Mutations
1127
1127
1128
-
When a mutation succeeds, it's likely that other queries in your application need to update. Where other libraries that use normalized caches would attempt to update locale queries with the new data imperatively, React Query helps you avoids the manual labor that comes with maintaining normalized caches and instead prescribes **atomic updates and refetching** instead of direct cache manipulation.
1128
+
When a mutation succeeds, it's likely that other queries in your application need to update. Where other libraries that use normalized caches would attempt to update local queries with the new data imperatively, React Query helps you to avoid the manual labor that comes with maintaining normalized caches and instead prescribes **atomic updates and refetching** instead of direct cache manipulation.
1129
1129
1130
1130
For example, assume we have a mutation to post a new todo:
You might find that you want to override some of `useMutation`'s options at the time of calling `mutate`. To do that, you can optionally override them by sending them through as options to the `mutate` function after your mutation variable. Supported option overrides are include:
1246
+
You might find that you want to override some of `useMutation`'s options at the time of calling `mutate`. To do that, you can optionally override them by sending them through as options to the `mutate` function after your mutation variable. Supported option overrides include:
0 commit comments