Skip to content

Commit 1282eda

Browse files
authored
Merge branch 'reduxjs:master' into docs-batch-correction
2 parents 0145e71 + 64a30d8 commit 1282eda

File tree

78 files changed

+2269
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2269
-167
lines changed
File renamed without changes.

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
fail-fast: false
9797
matrix:
9898
node: ['14.x']
99-
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6.1-rc', 'next']
99+
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6', '4.7']
100100
steps:
101101
- name: Checkout repo
102102
uses: actions/checkout@v2

docs/api/createAction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ This has different uses:
149149
150150
### As a TypeScript Type Guard
151151
152-
This `match` method is a [TypeScript type guard](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards) and can be used to discriminate the `payload` type of an action.
152+
This `match` method is a [TypeScript type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) and can be used to discriminate the `payload` type of an action.
153153
154154
This behavior can be particularly useful when used in custom middlewares, where manual casts might be neccessary otherwise.
155155

docs/api/createEntityAdapter.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ The primary content of an entity adapter is a set of generated reducer functions
208208
- `addOne`: accepts a single entity, and adds it if it's not already present.
209209
- `addMany`: accepts an array of entities or an object in the shape of `Record<EntityId, T>`, and adds them if not already present.
210210
- `setOne`: accepts a single entity and adds or replaces it
211-
- `setMany`: accepts an array of entities or an an object in the shape of `Record<EntityId, T>`, and adds or replaces them.
211+
- `setMany`: accepts an array of entities or an object in the shape of `Record<EntityId, T>`, and adds or replaces them.
212212
- `setAll`: accepts an array of entities or an object in the shape of `Record<EntityId, T>`, and replaces all existing entities with the values in the array.
213213
- `removeOne`: accepts a single entity ID value, and removes the entity with that ID if it exists.
214214
- `removeMany`: accepts an array of entity ID values, and removes each entity with those IDs if they exist.

docs/introduction/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The **Redux Toolkit** package is intended to be the standard way to write [Redux
2020
- "I have to add a lot of packages to get Redux to do anything useful"
2121
- "Redux requires too much boilerplate code"
2222

23-
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://www.apollographql.com/blog/announcement/frontend/zero-config-graphql-state-management/), we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
23+
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app), we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
2424

2525
Redux Toolkit also includes a powerful data fetching and caching capability that we've dubbed ["RTK Query"](#rtk-query). It's included in the package as a separate set of entry points. It's optional, but can eliminate the need to hand-write data fetching logic yourself.
2626

docs/rtk-query/api/created-api/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For maintainability purposes, you may wish to split up endpoint definitions acro
2626
```ts title="API Slice Contents" no-transpile
2727
const api = createApi({
2828
baseQuery: fetchBaseQuery({ baseUrl: '/' }),
29-
endpoints: (builder) => ({
29+
endpoints: (build) => ({
3030
// ...
3131
}),
3232
})

docs/rtk-query/overview.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ description: 'RTK Query > Overview: a summary of the RTK Query data caching API
2222

2323
RTK Query is **an optional addon included in the Redux Toolkit package**, and its functionality is built on top of the other APIs in Redux Toolkit.
2424

25+
:::info
26+
27+
To learn how to use RTK Query, see the full ["Redux Essentials" tutorial](https://redux.js.org/tutorials/essentials/part-7-rtk-query-basics) on the Redux core docs site.
28+
29+
:::
30+
2531
## Motivation
2632

2733
Web applications normally need to fetch data from a server in order to display it. They also usually need to make updates to that data, send those updates to the server, and keep the cached data on the client in sync with the data on the server. This is made more complicated by the need to implement other behaviors used in today's applications:

docs/rtk-query/usage-with-typescript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ function PostDetail() {
578578
if (error) {
579579
if ('status' in error) {
580580
// you can access all properties of `FetchBaseQueryError` here
581-
const errMsg = 'error' in err ? err.error : JSON.stringify(err.data)
581+
const errMsg = 'error' in error ? error.error : JSON.stringify(error.data)
582582

583583
return (
584584
<div>

docs/rtk-query/usage/customizing-queries.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,22 @@ const axiosBaseQuery =
251251
url: string
252252
method: AxiosRequestConfig['method']
253253
data?: AxiosRequestConfig['data']
254+
params?: AxiosRequestConfig['params']
254255
},
255256
unknown,
256257
unknown
257258
> =>
258-
async ({ url, method, data }) => {
259+
async ({ url, method, data, params }) => {
259260
try {
260-
const result = await axios({ url: baseUrl + url, method, data })
261+
const result = await axios({ url: baseUrl + url, method, data, params })
261262
return { data: result.data }
262263
} catch (axiosError) {
263264
let err = axiosError as AxiosError
264265
return {
265-
error: { status: err.response?.status, data: err.response?.data },
266+
error: {
267+
status: err.response?.status,
268+
data: err.response?.data || err.message
269+
},
266270
}
267271
}
268272
}

docs/rtk-query/usage/examples.mdx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,24 @@ We have a variety of examples that demonstrate various aspects of using RTK Quer
1616

1717
These examples are not meant to be what you base your application on, but exist to show _very specific_ behaviors that you may not actually want or need in your application. For most users, the basic examples in the [Queries](./queries) and [Mutations](./mutations) sections will cover the majority of your needs.
1818

19-
:::info
20-
21-
The examples were created as part of the standalone `@rtk-incubator/rtk-query` development cycle. We're currently working to update them as part of the process of finalizing RTK Query's integration into Redux Toolkit, so some of the imports are mismatched and not all the examples are currently in the RTK repo. However, you should be able to inspect these examples and use the logic they show as guidelines.
22-
23-
:::
24-
2519
:::tip
2620

2721
Please note that when playing with the examples in CodeSandbox that you can experience quirky behavior, especially if you fork them and start editing files. Hot reloading, CSB service workers and [`msw`](https://mswjs.io/) sometimes have trouble getting on the right page -- when that happens, just refresh in the CSB browser pane.
2822

2923
:::
3024

31-
## React Hooks
25+
## Kitchen Sink
3226

3327
<iframe
34-
src="https://codesandbox.io/embed/rtk-query-demo-lbp7n?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
28+
src="https://codesandbox.io/embed/github/reduxjs/redux-toolkit/tree/master/examples/query/react/kitchen-sink?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
3529
style={{
3630
width: '100%',
3731
height: '800px',
3832
border: 0,
3933
borderRadius: '4px',
4034
overflow: 'hidden',
4135
}}
42-
title="RTK Query React Hooks Example"
36+
title="RTK Query Kitchen Sink Example"
4337
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
4438
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
4539
></iframe>

0 commit comments

Comments
 (0)