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/rtk-query/usage/automated-refetching.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,7 @@ By declaring these tags as what can possibly be provided to the cache, it enable
108
108
109
109
### Providing cache data
110
110
111
-
Each individual `query` endpoint can have its cached data _provide_ particular tags. Doing so enables a relationship between cached data from one or more query endpoints and the behaviour of one or more mutation endpoints.
111
+
Each individual `query` endpoint can have its cached data _provide_ particular tags. Doing so enables a relationship between cached data from one or more query endpoints and the behavior of one or more mutation endpoints.
112
112
113
113
The `providesTags` property on a `query` endpoint is used for this purpose.
114
114
@@ -237,7 +237,7 @@ In order to provide stronger control over invalidating the appropriate data, you
237
237
238
238
### Invalidating cache data
239
239
240
-
Each individual mutation endpoint can `invalidate` particular tags for existing cached data. Doing so enables a relationship between cached data from one or more query endpoints and the behaviour of one or more mutation endpoints.
240
+
Each individual mutation endpoint can `invalidate` particular tags for existing cached data. Doing so enables a relationship between cached data from one or more query endpoints and the behavior of one or more mutation endpoints.
241
241
242
242
The `invalidatesTags` property on a mutation endpoint is used for this purpose.
243
243
@@ -621,7 +621,7 @@ A powerful use-case is to use an ID like `'LIST'` as a label for data provided b
621
621
622
622
:::
623
623
624
-
We can compare the scenarios below to see how using a `'LIST'` id can be leveraged to optimize behaviour.
624
+
We can compare the scenarios below to see how using a `'LIST'` id can be leveraged to optimize behavior.
625
625
626
626
#### Invalidating everything of a type
627
627
@@ -774,7 +774,7 @@ If you intend for the `addPost` mutation to refresh all posts including individu
774
774
775
775
The information provided to the cache is not limited to successful data fetches. The concept can be used to inform RTK Query that when a particular failure has been encountered, to `provide` a specific `tag` for that failed cache data. A separate endpoint can then `invalidate` the data for that `tag`, telling RTK Query to re-attempt the previously failed endpoints if a component is still subscribed to the failed data.
776
776
777
-
The example below demonstrates an example with the following behaviour:
777
+
The example below demonstrates an example with the following behavior:
778
778
779
779
- Provides an `UNAUTHORIZED` cache tag if a query fails with an error code of `401 UNAUTHORIZED`
780
780
- Provides an `UNKNOWN_ERROR` cache tag if a query fails with a different error
A key feature of RTK Query is its management of cached data. When data is fetched from the server, RTK Query will store the data in the Redux store as a 'cache'. When an additional request is performed for the same data, RTK Query will provide the existing cached data rather than sending an additional request to the server.
14
14
15
-
RTK Query provides a number of concepts and tools to manipulate the cache behaviour and adjust it to your needs.
15
+
RTK Query provides a number of concepts and tools to manipulate the cache behavior and adjust it to your needs.
16
16
17
17
## Default Cache Behavior
18
18
@@ -73,7 +73,7 @@ If 'ComponentThree' is unmounted in the example above, regardless of how much ti
73
73
74
74
## Manipulating Cache Behavior
75
75
76
-
On top of the default behaviour, RTK Query provides a number of methods to re-fetch data earlier in scenarios where it should be considered invalid, or is otherwise deemed suitable to be 'refreshed'.
76
+
On top of the default behavior, RTK Query provides a number of methods to re-fetch data earlier in scenarios where it should be considered invalid, or is otherwise deemed suitable to be 'refreshed'.
77
77
78
78
### Reducing subscription time with `keepUnusedDataFor`
Copy file name to clipboardExpand all lines: docs/rtk-query/usage/customizing-queries.mdx
+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
@@ -18,7 +18,7 @@ The default method to handle queries is via the [`baseQuery`](../api/createApi#b
18
18
19
19
To process queries, endpoints are defined with a [`query`](../api/createApi.mdx#query) option, which passes its return value to a common [`baseQuery`](../api/createApi#basequery) function used for the API.
20
20
21
-
By default, RTK Query ships with [`fetchBaseQuery`](../api/fetchBaseQuery), which is a lightweight [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) wrapper that automatically handles request headers and response parsing in a manner similar to common libraries like `axios`. If `fetchBaseQuery` alone does not meet your needs, you can customize its behaviour with a wrapper function, or create your own [`baseQuery`](../api/createApi.mdx#basequery) function from scratch for [`createApi`](../api/createApi) to use.
21
+
By default, RTK Query ships with [`fetchBaseQuery`](../api/fetchBaseQuery), which is a lightweight [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) wrapper that automatically handles request headers and response parsing in a manner similar to common libraries like `axios`. If `fetchBaseQuery` alone does not meet your needs, you can customize its behavior with a wrapper function, or create your own [`baseQuery`](../api/createApi.mdx#basequery) function from scratch for [`createApi`](../api/createApi) to use.
22
22
23
23
See also [`baseQuery API Reference`](../api/createApi.mdx#basequery).
24
24
@@ -263,15 +263,15 @@ RTK Query comes with `fetchBaseQuery` out of the box, which makes it straightfor
263
263
264
264
RTK Query supports defining endpoints that run arbitrary async logic and return a result. Individual endpoints on [`createApi`](../api/createApi.mdx) accept a [`queryFn`](../api/createApi.mdx#queryfn) property, which let you write your own async function with whatever logic you want inside.
265
265
266
-
This can be useful for scenarios where you want to have particularly different behaviour for a single endpoint, or where the query itself is not relevant, including:
266
+
This can be useful for scenarios where you want to have particularly different behavior for a single endpoint, or where the query itself is not relevant, including:
267
267
268
268
- One-off queries that use a different base URL
269
269
- One-off queries that use different request handling, such as automatic re-tries
270
-
- One-off queries that use different error handling behaviour
270
+
- One-off queries that use different error handling behavior
271
271
- Queries that make requests using a third-party library SDK, such as Firebase or Supabase
272
272
- Queries that perform async tasks that are not a typical request/response
273
273
- Performing multiple requests with a single query ([example](#performing-multiple-requests-with-a-single-query))
274
-
- Leveraging invalidation behaviour with no relevant query ([example](#using-a-no-op-queryfn))
274
+
- Leveraging invalidation behavior with no relevant query ([example](#using-a-no-op-queryfn))
275
275
- Using [Streaming Updates](./streaming-updates) with no relevant initial request ([example](#streaming-data-with-no-initial-request))
276
276
277
277
See also [`queryFn API Reference`](../api/createApi.mdx#queryfn) for the type signature and available options.
Copy file name to clipboardExpand all lines: docs/rtk-query/usage/migrating-to-rtk-query.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ The most common use case for side effects in Redux apps is fetching data. Redux
22
22
23
23
RTK Query is purpose-built to solve the use case of data fetching. While it can't replace all of the situations where you'd use thunks or other side effects approaches, **using RTK Query should eliminate the need for most of that hand-written side effects logic**.
24
24
25
-
RTK Query is expected to cover a lot of overlapping behaviour that users may have previously used `createAsyncThunk` for, including caching purposes, and request lifecycle management (e.g. `isUninitialized`, `isLoading`, `isError` states).
25
+
RTK Query is expected to cover a lot of overlapping behavior that users may have previously used `createAsyncThunk` for, including caching purposes, and request lifecycle management (e.g. `isUninitialized`, `isLoading`, `isError` states).
26
26
27
27
In order to migrate data-fetching features from existing Redux tools to RTK Query, the appropriate endpoints should be added to an RTK Query API slice, and the previous feature code deleted. This generally will not include much common code kept between the two, as the tools work differently and one will replace the other.
28
28
@@ -271,7 +271,7 @@ export function useGetPokemonByNameQuery(name: string) {
271
271
272
272
Our code above meets all of the design specifications, so let's use it! Below we can see how the hook can be called in a component, and return the relevant data & status booleans.
273
273
274
-
Our implementation below provides the following behaviour in the component:
274
+
Our implementation below provides the following behavior in the component:
275
275
276
276
- When our component is mounted, if a request for the provided pokemon name has not already been sent for the session, send the request off
277
277
- The hook always provides the latest received `data` when available, as well as the request status booleans `isUninitialized`, `isPending`, `isFulfilled` & `isRejected` in order to determine the current UI at any given moment as a function of our state.
Copy file name to clipboardExpand all lines: docs/rtk-query/usage/queries.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -330,7 +330,7 @@ function PostsList() {
330
330
}
331
331
```
332
332
333
-
To summarize the above behaviour - the returned values must be correctly memoized. See also [Deriving Data with Selectors](https://redux.js.org/usage/deriving-data-selectors) and [Redux Essentials - RTK Query Advanced Patterns](https://redux.js.org/tutorials/essentials/part-8-rtk-query-advanced#selecting-values-from-results) for additional information.
333
+
To summarize the above behavior - the returned values must be correctly memoized. See also [Deriving Data with Selectors](https://redux.js.org/usage/deriving-data-selectors) and [Redux Essentials - RTK Query Advanced Patterns](https://redux.js.org/tutorials/essentials/part-8-rtk-query-advanced#selecting-values-from-results) for additional information.
Copy file name to clipboardExpand all lines: docs/rtk-query/usage/usage-without-react-hooks.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ The `endpoint.select(arg)` function creates a _new_ selector instance - it isn't
55
55
56
56
:::
57
57
58
-
With React hooks, this behaviour is instead handled within [`useQuery`](../api/created-api/hooks.mdx#usequery), [`useQueryState`](../api/created-api/hooks.mdx#usequerystate), and [`useLazyQuery`](../api/created-api/hooks.mdx#uselazyquery).
58
+
With React hooks, this behavior is instead handled within [`useQuery`](../api/created-api/hooks.mdx#usequery), [`useQueryState`](../api/created-api/hooks.mdx#usequerystate), and [`useLazyQuery`](../api/created-api/hooks.mdx#uselazyquery).
59
59
60
60
```ts title="Accessing cached data & request status" no-transpile
61
61
const result =api.endpoints.getPosts.select()(state)
0 commit comments