Skip to content

Commit ef49075

Browse files
committed
Merge branch 'master' into v2.0-integration
# Conflicts: # packages/toolkit/package.json # packages/toolkit/src/tests/__snapshots__/serializableStateInvariantMiddleware.test.ts.snap # packages/toolkit/src/tests/configureStore.typetest.ts
2 parents 0974d81 + a636751 commit ef49075

39 files changed

+574
-137
lines changed

docs/api/immutabilityMiddleware.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ interface ImmutableStateInvariantMiddlewareOptions {
2929
*/
3030
isImmutable?: IsImmutableFunc
3131
/**
32-
An array of dot-separated path strings that match named nodes from
32+
An array of dot-separated path strings or RegExps that match named nodes from
3333
the root state to ignore when checking for immutability.
3434
Defaults to undefined
3535
*/
36-
ignoredPaths?: string[]
36+
ignoredPaths?: (string | RegExp)[]
3737
/** Print a warning if checks take longer than N ms. Default: 32ms */
3838
warnAfter?: number
3939
// @deprecated. Use ignoredPaths

docs/api/otherExports.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ The default immutable update function from the [`immer` library](https://immerjs
5858

5959
[The `current` function](https://immerjs.github.io/immer/current) from the [`immer` library](https://immerjs.github.io/immer/), which takes a snapshot of the current state of a draft and finalizes it (but without freezing). Current is a great utility to print the current state during debugging, and the output of `current` can also be safely leaked outside the producer.
6060

61-
### `original`
62-
63-
[The `original` function](https://immerjs.github.io/immer/original) from the [`immer` library](https://immerjs.github.io/immer/), which returns the original object. This is particularly useful for referential equality check in reducers.
64-
6561
```ts
6662
import { createReducer, createAction, current } from '@reduxjs/toolkit'
6763

@@ -80,6 +76,10 @@ const todosReducer = createReducer(initialState, (builder) => {
8076
})
8177
```
8278

79+
### `original`
80+
81+
[The `original` function](https://immerjs.github.io/immer/original) from the [`immer` library](https://immerjs.github.io/immer/), which returns the original object. This is particularly useful for referential equality check in reducers.
82+
8383
### `isDraft`
8484

8585
[The `isDraft` function](https://immerjs.github.io/immer/original) from the [`immer` library](https://immerjs.github.io/immer/), which checks to see if a given value is a Proxy-wrapped "draft" state.

docs/api/serializabilityMiddleware.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ interface SerializableStateInvariantMiddlewareOptions {
3939
ignoredActions?: string[]
4040

4141
/**
42-
* An array of dot-separated path strings to ignore when checking
43-
* for serializability, Defaults to ['meta.arg', 'meta.baseQueryMeta']
42+
* An array of dot-separated path strings or regular expressions to ignore
43+
* when checking for serializability, Defaults to
44+
* ['meta.arg', 'meta.baseQueryMeta']
4445
*/
45-
ignoredActionPaths?: string[]
46+
ignoredActionPaths?: (string | RegExp)[]
4647

4748
/**
48-
* An array of dot-separated path strings to ignore when checking
49-
* for serializability, Defaults to []
49+
* An array of dot-separated path strings or regular expressions to ignore
50+
* when checking for serializability, Defaults to []
5051
*/
51-
ignoredPaths?: string[]
52+
ignoredPaths?: (string | RegExp)[]
5253
/**
5354
* Execution time warning threshold. If the middleware takes longer
5455
* than `warnAfter` ms, a warning will be displayed in the console.

docs/introduction/getting-started.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ hide_title: true
77

88
import LiteYouTubeEmbed from 'react-lite-youtube-embed';
99
import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'
10+
import Tabs from '@theme/Tabs';
11+
import TabItem from '@theme/TabItem';
1012

1113
 
1214

@@ -46,18 +48,35 @@ npx create-react-app my-app --template redux-typescript
4648

4749
Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application:
4850

51+
<Tabs>
52+
<TabItem value="npm" label="npm" default>
53+
4954
```bash
50-
# NPM
5155
npm install @reduxjs/toolkit
5256
```
5357

54-
or
58+
If you need React bindings:
59+
60+
```bash
61+
npm install react-redux
62+
```
63+
64+
</TabItem>
65+
<TabItem value="yarn" label="yarn" default>
5566

5667
```bash
57-
# Yarn
5868
yarn add @reduxjs/toolkit
5969
```
6070

71+
If you need React bindings:
72+
73+
```bash
74+
yarn add react-redux
75+
```
76+
77+
</TabItem>
78+
</Tabs>
79+
6180
It is also available as a precompiled UMD package that defines a `window.RTK` global variable.
6281
The UMD package can be used as a [`<script>` tag](https://unpkg.com/@reduxjs/toolkit/dist/redux-toolkit.umd.js) directly.
6382

docs/rtk-query/api/createApi.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ export const { useGetPokemonByNameQuery } = pokemonApi
8282
#### baseQuery function arguments
8383

8484
- `args` - The return value of the `query` function for a given endpoint
85-
- `api` - The `BaseQueryApi` object, containing `signal`, `dispatch`, `getState` and `extra` properties
85+
- `api` - The `BaseQueryApi` object contains:
8686
- `signal` - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) object that may be used to abort DOM requests and/or read whether the request is aborted.
87+
- `abort` - The [`abort()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) method of the AbortController attached to `signal`.
8788
- `dispatch` - The `store.dispatch` method for the corresponding Redux store
8889
- `getState` - A function that may be called to access the current store state
8990
- `extra` - Provided as thunk.extraArgument to the configureStore getDefaultMiddleware option.
91+
- `endpoint` - The name of the endpoint.
92+
- `type` - Type of request (`query` or `mutation`).
93+
- `forced` - Indicates if a query has been forced.
9094
- `extraOptions` - The value of the optional `extraOptions` property provided for a given endpoint
9195

9296
#### baseQuery function signature
@@ -106,8 +110,13 @@ export type BaseQueryFn<
106110

107111
export interface BaseQueryApi {
108112
signal: AbortSignal
113+
abort: (reason?: string) => void
109114
dispatch: ThunkDispatch<any, any, any>
110115
getState: () => unknown
116+
extra: unknown
117+
endpoint: string
118+
type: 'query' | 'mutation'
119+
forced?: boolean
111120
}
112121

113122
export type QueryReturnValue<T = unknown, E = unknown, M = unknown> =

docs/rtk-query/usage/code-generation.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ interface SimpleUsage {
107107
| EndpointMatcherFunction
108108
| Array<string | RegExp | EndpointMatcherFunction>
109109
endpointOverrides?: EndpointOverrides[]
110+
flattenArg?: boolean
110111
}
111112

112113
export type EndpointMatcherFunction = (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ See also [Websocket Chat API with a transformed response shape](./streaming-upda
177177

178178
## Customizing query responses with `transformErrorResponse`
179179

180-
Individual endpoints on [`createApi`](../api/createApi.mdx) accept a [`transformErrorResponse`](../api/createApi.mdx) property which allows manipulation of the errir returned by a query or mutation before it hits the cache.
180+
Individual endpoints on [`createApi`](../api/createApi.mdx) accept a [`transformErrorResponse`](../api/createApi.mdx) property which allows manipulation of the error returned by a query or mutation before it hits the cache.
181181

182182
`transformErrorResponse` is called with the error that a failed `baseQuery` returns for the corresponding endpoint, and the return value of `transformErrorResponse` is used as the cached error associated with that endpoint call.
183183

packages/rtk-codemods/bin/cli.js

100644100755
File mode changed.

packages/toolkit/etc/redux-toolkit.api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ export function findNonSerializableValue(
511511
path?: string,
512512
isSerializable?: (value: unknown) => boolean,
513513
getEntries?: (value: unknown) => [string, any][],
514-
ignoredPaths?: readonly string[]
514+
ignoredPaths?: readonly (string | RegExp)[]
515515
): NonSerializableValue | false
516516

517517
export { freeze }
@@ -762,9 +762,9 @@ export { Selector }
762762
// @public
763763
export interface SerializableStateInvariantMiddlewareOptions {
764764
getEntries?: (value: any) => [string, any][]
765-
ignoredActionPaths?: string[]
765+
ignoredActionPaths?: (string | RegExp)[]
766766
ignoredActions?: string[]
767-
ignoredPaths?: string[]
767+
ignoredPaths?: (string | RegExp)[]
768768
ignoreState?: boolean
769769
isSerializable?: (value: any) => boolean
770770
warnAfter?: number

packages/toolkit/src/entities/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export { createEntityAdapter } from './create_adapter'
2-
export {
2+
export type {
33
Dictionary,
44
EntityState,
55
EntityAdapter,

0 commit comments

Comments
 (0)