Skip to content

Commit c2cfd23

Browse files
authored
Merge branch 'master' into retry-error-type
2 parents 5690e9d + d36a3a1 commit c2cfd23

File tree

553 files changed

+45221
-11497
lines changed

Some content is hidden

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

553 files changed

+45221
-11497
lines changed

.github/workflows/tests.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
- name: Install build artifact
9292
run: yarn workspace @reduxjs/toolkit add $(pwd)/package.tgz
9393

94-
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.ts ./src/tests/*.* ./src/query/tests/*.*
94+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.mts ./src/tests/*.* ./src/query/tests/*.*
9595

9696
- name: Run tests, against dist
9797
run: yarn test
@@ -133,7 +133,7 @@ jobs:
133133
- name: Show installed RTK versions
134134
run: yarn info @reduxjs/toolkit
135135

136-
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.ts ./src/tests/*.* ./src/query/tests/*.*
136+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.mts ./src/tests/*.* ./src/query/tests/*.*
137137

138138
- name: Test types
139139
run: |
@@ -149,7 +149,17 @@ jobs:
149149
fail-fast: false
150150
matrix:
151151
node: ['18.x']
152-
example: ['cra4', 'cra5', 'next', 'vite', 'node-standard', 'node-esm']
152+
example:
153+
[
154+
'cra4',
155+
'cra5',
156+
'next',
157+
'vite',
158+
'node-standard',
159+
'node-esm',
160+
'react-native',
161+
'expo',
162+
]
153163
defaults:
154164
run:
155165
working-directory: ./examples/publish-ci/${{ matrix.example }}
@@ -183,6 +193,13 @@ jobs:
183193
- name: Show installed RTK versions
184194
run: yarn info @reduxjs/toolkit && yarn why @reduxjs/toolkit
185195

196+
- name: Set up JDK 17 for React Native build
197+
if: matrix.example == 'react-native' || matrix.example == 'expo'
198+
uses: actions/setup-java@v2
199+
with:
200+
java-version: '17.x'
201+
distribution: 'temurin'
202+
186203
- name: Build example
187204
run: NODE_OPTIONS=--openssl-legacy-provider yarn build
188205

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ typesversions
3030
!.yarn/versions
3131
.pnp.*
3232
*.tgz
33+
34+
tsconfig.vitest-temp.json

.prettierrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
"singleQuote": true,
44
"endOfLine": "auto"
55
}
6-

.yarn/patches/msw-npm-0.40.2-2107d48752

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

.yarn/releases/yarn-3.2.4.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/api/actionCreatorMiddleware.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import reducer from './reducer'
5353

5454
// Augment middleware to consider all functions with a static type property to be action creators
5555
const isActionCreator = (
56-
action: unknown
56+
action: unknown,
5757
): action is Function & { type: unknown } =>
5858
typeof action === 'function' && 'type' in action
5959

docs/api/combineSlices.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@ declare module '.' {
235235

236236
const withInjected = rootReducer.inject(
237237
{ reducerPath: 'removable', reducer: removableReducer },
238-
{ overrideExisting: true }
238+
{ overrideExisting: true },
239239
)
240240

241241
const emptyReducer = () => null
242242

243243
const removeReducer = () =>
244244
rootReducer.inject(
245245
{ reducerPath: 'removable', reducer: emptyReducer },
246-
{ overrideExisting: true }
246+
{ overrideExisting: true },
247247
)
248248
```
249249

@@ -273,14 +273,14 @@ const withCounter = rootReducer.inject(counterSlice)
273273
const selectCounterValue = (rootState: RootState) => rootState.counter?.value // number | undefined
274274

275275
const wrappedSelectCounterValue = withCounter.selector(
276-
(rootState) => rootState.counter.value // number
276+
(rootState) => rootState.counter.value, // number
277277
)
278278

279279
console.log(
280280
selectCounterValue({}), // undefined
281281
selectCounterValue({ counter: { value: 2 } }), // 2
282282
wrappedSelectCounterValue({}), // 0
283-
wrappedSelectCounterValue({ counter: { value: 2 } }) // 2
283+
wrappedSelectCounterValue({ counter: { value: 2 } }), // 2
284284
)
285285
```
286286

@@ -303,7 +303,7 @@ interface RootState {
303303

304304
const selectCounterValue = withCounter.selector(
305305
(combinedState) => combinedState.counter.value,
306-
(rootState: RootState) => rootState.innerCombined
306+
(rootState: RootState) => rootState.innerCombined,
307307
)
308308

309309
console.log(
@@ -316,7 +316,7 @@ console.log(
316316
value: 2,
317317
},
318318
},
319-
}) // 2
319+
}), // 2
320320
)
321321
```
322322

@@ -365,6 +365,6 @@ If the slice state is undefined in the store state passed, the selector will ins
365365
console.log(
366366
injectedCounterSlice.selectors.selectValue({}), // 0
367367
injectedCounterSlice.selectors.selectValue({ counter: { value: 2 } }), // 2
368-
aCounterSlice.selectors.selectValue({ aCounter: { value: 2 } }) // 2
368+
aCounterSlice.selectors.selectValue({ aCounter: { value: 2 } }), // 2
369369
)
370370
```

docs/api/configureStore.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ interface ConfigureStoreOptions<
4646
P = S
4747
> {
4848
/**
49+
* A single reducer function that will be used as the root reducer, or an
50+
* object of slice reducers that will be passed to `combineReducers()`.
51+
*/
52+
reducer: Reducer<S, A, P> | ReducersMapObject<S, A, P>
4953

5054
/**
5155
* An array of Redux middleware to install. If not supplied, defaults to

docs/api/createAction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,6 @@ export const epic = (actions$: Observable<Action>) =>
148148
map((action) => {
149149
// action.payload can be safely used as number here (and will also be correctly inferred by TypeScript)
150150
// ...
151-
})
151+
}),
152152
)
153153
```

docs/api/createAsyncThunk.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const fetchUserById = createAsyncThunk(
3535
async (userId: number, thunkAPI) => {
3636
const response = await userAPI.fetchById(userId)
3737
return response.data
38-
}
38+
},
3939
)
4040

4141
interface UsersState {
@@ -190,23 +190,23 @@ interface RejectedWithValueAction<ThunkArg, RejectedValue> {
190190

191191
type Pending = <ThunkArg>(
192192
requestId: string,
193-
arg: ThunkArg
193+
arg: ThunkArg,
194194
) => PendingAction<ThunkArg>
195195

196196
type Fulfilled = <ThunkArg, PromiseResult>(
197197
payload: PromiseResult,
198198
requestId: string,
199-
arg: ThunkArg
199+
arg: ThunkArg,
200200
) => FulfilledAction<ThunkArg, PromiseResult>
201201

202202
type Rejected = <ThunkArg>(
203203
requestId: string,
204-
arg: ThunkArg
204+
arg: ThunkArg,
205205
) => RejectedAction<ThunkArg>
206206

207207
type RejectedWithValue = <ThunkArg, RejectedValue>(
208208
requestId: string,
209-
arg: ThunkArg
209+
arg: ThunkArg,
210210
) => RejectedWithValueAction<ThunkArg, RejectedValue>
211211
```
212212
@@ -365,7 +365,7 @@ const updateUser = createAsyncThunk(
365365
// by explicitly returning it using the `rejectWithValue()` utility
366366
return rejectWithValue(err.response.data)
367367
}
368-
}
368+
},
369369
)
370370
```
371371

@@ -391,7 +391,7 @@ const fetchUserById = createAsyncThunk(
391391
return false
392392
}
393393
},
394-
}
394+
},
395395
)
396396
```
397397

@@ -419,7 +419,7 @@ export const fetchUserById = createAsyncThunk(
419419
'fetchUserById',
420420
(userId: string) => {
421421
/* ... */
422-
}
422+
},
423423
)
424424

425425
// file: MyComponent.ts
@@ -456,7 +456,7 @@ const fetchUserById = createAsyncThunk(
456456
signal: thunkAPI.signal,
457457
})
458458
return await response.json()
459-
}
459+
},
460460
)
461461
```
462462

@@ -486,7 +486,7 @@ const readStream = createAsyncThunk(
486486
done = read.done
487487
}
488488
return result
489-
}
489+
},
490490
)
491491
```
492492

@@ -510,7 +510,7 @@ const fetchUserById = createAsyncThunk(
510510
cancelToken: source.token,
511511
})
512512
return response.data
513-
}
513+
},
514514
)
515515
```
516516

@@ -527,7 +527,7 @@ If a thunk was cancelled, the result of the promise will be a `rejected` action
527527
So if you wanted to test that a thunk was cancelled before executing, you can do the following:
528528

529529
```ts no-transpile
530-
import { createAsyncThunk, isRejected } from '@reduxjs/toolkit'
530+
import { createAsyncThunk } from '@reduxjs/toolkit'
531531

532532
test('this thunk should always be skipped', async () => {
533533
const thunk = createAsyncThunk(
@@ -749,7 +749,7 @@ const UsersComponent = (props: { id: string }) => {
749749
// This is an example of an onSubmit handler using Formik meant to demonstrate accessing the payload of the rejected action
750750
const handleUpdateUser = async (
751751
values: FormValues,
752-
formikHelpers: FormikHelpers<FormValues>
752+
formikHelpers: FormikHelpers<FormValues>,
753753
) => {
754754
const resultAction = await dispatch(updateUser({ id: props.id, ...values }))
755755
if (updateUser.fulfilled.match(resultAction)) {

0 commit comments

Comments
 (0)