Skip to content

Commit 4a07d0b

Browse files
committed
Merge branch 'master' into create-slice-creators
2 parents 2d7def1 + 68bf4b6 commit 4a07d0b

File tree

297 files changed

+67461
-47576
lines changed

Some content is hidden

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

297 files changed

+67461
-47576
lines changed

.codesandbox/ci.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"/examples/action-listener/counter",
88
"/examples/publish-ci/cra5"
99
],
10-
"node": "18",
10+
"node": "20",
1111
"buildCommand": "build:packages",
1212
"packages": [
1313
"packages/toolkit",

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/checkout@v4
2525
- uses: actions/setup-node@v4
2626
with:
27-
node-version: '20.x'
27+
node-version: '22.x'
2828
registry-url: 'https://registry.npmjs.org'
2929
cache: 'yarn'
3030
- run: yarn install --frozen-lockfile

.github/workflows/size.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
pull_request:
44
branches:
55
- master
6+
- 'feature/infinite-query-integration'
67
permissions:
78
pull-requests: write
89
jobs:

.github/workflows/test-codegen.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
strategy:
4141
matrix:
42-
node-version: ['20.x']
42+
node-version: ['22.x']
4343
os: [ubuntu-latest]
4444

4545
steps:
@@ -79,7 +79,7 @@ jobs:
7979
strategy:
8080
fail-fast: false
8181
matrix:
82-
node-version: [20.x]
82+
node-version: [22.x]
8383
os: [ubuntu-latest]
8484

8585
steps:
@@ -125,7 +125,7 @@ jobs:
125125
strategy:
126126
fail-fast: false
127127
matrix:
128-
node-version: [20.x]
128+
node-version: [22.x]
129129
steps:
130130
- name: Checkout repo
131131
uses: actions/checkout@v4

.github/workflows/tests.yml

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
strategy:
3333
matrix:
34-
node: ['20.x']
34+
node: ['22.x']
3535

3636
steps:
3737
- name: Checkout repo
@@ -62,13 +62,27 @@ jobs:
6262
path: packages/toolkit/package.tgz
6363

6464
test-dist:
65-
name: Test against dist
65+
name: Run local tests against build artifact (React ${{ matrix.react.version }})
6666
needs: [build]
6767
runs-on: ubuntu-latest
6868
strategy:
6969
fail-fast: false
7070
matrix:
71-
node: ['20.x']
71+
node: ['22.x']
72+
react:
73+
[
74+
{
75+
version: '^18',
76+
types: ^18,
77+
react-dom: { version: '^18', types: '^18' },
78+
},
79+
{
80+
version: '^19',
81+
types: '^19',
82+
react-dom: { version: '^19', types: '^19' },
83+
},
84+
]
85+
7286
steps:
7387
- name: Checkout repo
7488
uses: actions/checkout@v4
@@ -82,36 +96,63 @@ jobs:
8296
- name: Install deps
8397
run: yarn install
8498

85-
- uses: actions/download-artifact@v4
99+
- name: Download build artifact
100+
uses: actions/download-artifact@v4
86101
with:
87102
name: package
88103
path: packages/toolkit
89104

90-
- run: ls -lah
105+
- name: Check folder contents
106+
run: ls -lah
107+
108+
- name: Install React ${{ matrix.react.version }} and React-DOM ${{ matrix.react.react-dom.version }}
109+
run: yarn up react@${{ matrix.react.version }} react-dom@${{ matrix.react.react-dom.version }} @types/react@${{ matrix.react.types }} @types/react-dom@${{ matrix.react.react-dom.types }}
91110

92111
- name: Install build artifact
93112
run: yarn workspace @reduxjs/toolkit add $(pwd)/package.tgz
94113

95-
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json
96-
97-
- name: Run tests, against dist
98-
env:
99-
TEST_DIST: true
100-
run: yarn test
114+
- name: Erase path aliases
115+
run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json
101116

102117
- name: Run type tests with `moduleResolution Bundler`
103118
run: rm -rf dist && yarn tsc -p . --moduleResolution Bundler --module ESNext --noEmit false --declaration --emitDeclarationOnly --outDir dist --target ESNext && rm -rf dist
104119

120+
- name: Ensure there's no dist folder
121+
run: rm -rf dist
122+
123+
- name: Change RTK package name to ensure node_modules is used
124+
run: sed -i -e 's|@reduxjs/toolkit|@reduxjs/toolkit-test|' ./package.json
125+
126+
- name: Run tests, against installed artifact
127+
env:
128+
TEST_DIST: true
129+
working-directory: ./packages/toolkit
130+
run: ../../node_modules/.bin/vitest --run --typecheck
131+
105132
test-types:
106-
name: 'Test Types: TS ${{ matrix.ts }}'
133+
name: 'Test Types: TS ${{ matrix.ts }} and React ${{ matrix.react.version }}'
107134

108135
needs: [build]
109136
runs-on: ubuntu-latest
110137
strategy:
111138
fail-fast: false
112139
matrix:
113-
node: ['20.x']
114-
ts: ['5.0', '5.1', '5.2', '5.3', '5.4', '5.5']
140+
node: ['22.x']
141+
ts: ['5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8']
142+
react:
143+
[
144+
{
145+
version: '^18',
146+
types: ^18,
147+
react-dom: { version: '^18', types: '^18' },
148+
},
149+
{
150+
version: '^19',
151+
types: '^19',
152+
react-dom: { version: '^19', types: '^19' },
153+
},
154+
]
155+
115156
steps:
116157
- name: Checkout repo
117158
uses: actions/checkout@v4
@@ -125,6 +166,9 @@ jobs:
125166
- name: Install deps
126167
run: yarn install
127168

169+
- name: Install React ${{ matrix.react.version }} and React-DOM ${{ matrix.react.react-dom.version }}
170+
run: yarn up react@${{ matrix.react.version }} react-dom@${{ matrix.react.react-dom.version }} @types/react@${{ matrix.react.types }} @types/react-dom@${{ matrix.react.react-dom.types }}
171+
128172
- name: Install TypeScript ${{ matrix.ts }}
129173
run: yarn add typescript@${{ matrix.ts }}
130174

@@ -139,7 +183,8 @@ jobs:
139183
- name: Show installed RTK versions
140184
run: yarn info @reduxjs/toolkit
141185

142-
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json
186+
- name: Erase path aliases
187+
run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json
143188

144189
- name: Test types
145190
env:
@@ -156,7 +201,7 @@ jobs:
156201
strategy:
157202
fail-fast: false
158203
matrix:
159-
node: ['20.x']
204+
node: ['22.x']
160205
example:
161206
[
162207
'cra4',
@@ -203,12 +248,13 @@ jobs:
203248
- name: Show installed RTK versions
204249
run: yarn info @reduxjs/toolkit && yarn why @reduxjs/toolkit
205250

206-
- name: Set up JDK 17 for React Native build
251+
- name: Set up JDK 21 for React Native build
207252
if: matrix.example == 'react-native' || matrix.example == 'expo'
208253
uses: actions/setup-java@v4
209254
with:
210-
java-version: '17.x'
255+
java-version: '21.x'
211256
distribution: 'temurin'
257+
cache: 'gradle'
212258

213259
- name: Build example
214260
env:
@@ -226,7 +272,7 @@ jobs:
226272
strategy:
227273
fail-fast: false
228274
matrix:
229-
node: ['20.x']
275+
node: ['22.x']
230276
steps:
231277
- name: Checkout repo
232278
uses: actions/checkout@v4
@@ -258,8 +304,8 @@ jobs:
258304
strategy:
259305
fail-fast: false
260306
matrix:
261-
node: ['20.x']
262-
ts: ['5.3', '5.4', '5.5', 'next']
307+
node: ['22.x']
308+
ts: ['5.3', '5.4', '5.5', '5.6', '5.7', '5.8', 'next']
263309
example:
264310
[
265311
{ name: 'bundler', moduleResolution: 'Bundler' },

.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch

Lines changed: 0 additions & 68 deletions
This file was deleted.

.yarn/patches/console-testing-library__npm_0.3.1.patch

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/api/configureStore.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ interface ConfigureStoreOptions<
6464
*/
6565
devTools?: boolean | DevToolsOptions
6666

67+
/**
68+
* Whether to check for duplicate middleware instances. Defaults to `true`.
69+
*/
70+
duplicateMiddlewareCheck?: boolean
71+
6772
/**
6873
* The initial state, same as Redux's createStore.
6974
* You may optionally specify it to hydrate the state
@@ -142,6 +147,12 @@ a list of the specific options that are available.
142147

143148
Defaults to `true`.
144149

150+
### `duplicateMiddlewareCheck`
151+
152+
If enabled, the store will check the final middleware array to see if there are any duplicate middleware references. This will catch issues like accidentally adding the same RTK Query API middleware twice (such as adding both the base API middleware and an injected API middleware, which are actually the exact same function reference).
153+
154+
Defaults to `true`.
155+
145156
#### `trace`
146157

147158
The Redux DevTools Extension recently added [support for showing action stack traces](https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/Features/Trace.md) that show exactly where each action was dispatched.

docs/api/createAsyncThunk.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ An object with the following optional fields:
108108

109109
- `condition(arg, { getState, extra } ): boolean | Promise<boolean>`: a callback that can be used to skip execution of the payload creator and all action dispatches, if desired. See [Canceling Before Execution](#canceling-before-execution) for a complete description.
110110
- `dispatchConditionRejection`: if `condition()` returns `false`, the default behavior is that no actions will be dispatched at all. If you still want a "rejected" action to be dispatched when the thunk was canceled, set this flag to `true`.
111-
- `idGenerator(arg): string`: a function to use when generating the `requestId` for the request sequence. Defaults to use [nanoid](./otherExports.mdx/#nanoid), but you can implement your own ID generation logic.
111+
- `idGenerator(arg): string`: a function to use when generating the `requestId` for the request sequence. Defaults to use [nanoid](./otherExports.mdx#nanoid), but you can implement your own ID generation logic.
112112
- `serializeError(error: unknown) => any` to replace the internal `miniSerializeError` method with your own serialization logic.
113113
- `getPendingMeta({ arg, requestId }, { getState, extra }): any`: a function to create an object that will be merged into the `pendingAction.meta` field.
114114

@@ -133,6 +133,18 @@ When dispatched, the thunk will:
133133
- if the promise failed and was not handled with `rejectWithValue`, dispatch the `rejected` action with a serialized version of the error value as `action.error`
134134
- Return a fulfilled promise containing the final dispatched action (either the `fulfilled` or `rejected` action object)
135135

136+
## Thunk Dispatch Options
137+
138+
The returned thunk action creator accepts an optional second argument with the following options:
139+
140+
- `signal`: an optional [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) that will be tracked by the internal abort signal (see [Canceling While Running](#canceling-while-running))
141+
142+
```ts no-transpile
143+
const externalController = new AbortController()
144+
dispatch(fetchUserById(123, { signal: externalController.signal }))
145+
externalController.abort()
146+
```
147+
136148
## Promise Lifecycle Actions
137149

138150
`createAsyncThunk` will generate three Redux action creators using [`createAction`](./createAction.mdx): `pending`, `fulfilled`, and `rejected`. Each lifecycle action creator will be attached to the returned thunk action creator so that your reducer logic can reference the action types and respond to the actions when dispatched. Each action object will contain the current unique `requestId` and `arg` values under `action.meta`.

docs/api/createEntityAdapter.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ const globalizedSelectors = booksAdapter.getSelectors((state) => state.books, {
341341
})
342342
```
343343

344-
If no instance is passed, it will default to [`createDraftSafeSelector`](./createSelector#createDraftSafeSelector).
344+
If no instance is passed, it will default to [`createDraftSafeSelector`](./createSelector.mdx#createdraftsafeselector).
345345

346346
:::
347347

docs/api/createSlice.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ As a result, there are two ways of getting final selectors:
504504

505505
#### `selectors`
506506

507-
Most commonly, the slice is reliably mounted under its [`reducerPath`](#reducerPath).
507+
Most commonly, the slice is reliably mounted under its [`reducerPath`](#reducerpath).
508508

509509
Following this, the slice has a `selectSlice` selector attached, which assumes that the slice is located under `rootState[slice.reducerPath]`.
510510

0 commit comments

Comments
 (0)