Skip to content

Commit 7276087

Browse files
author
ben.durrant
committed
Merge branch 'v2.0-integration' into pr/configure-produce-implementation
2 parents 30b1b49 + 3c0546a commit 7276087

File tree

179 files changed

+4739
-4904
lines changed

Some content is hidden

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

179 files changed

+4739
-4904
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github: [phryneas, markerikson]
1+
github: [phryneas, markerikson, EskiMojo14]

.github/workflows/tests.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
fail-fast: false
106106
matrix:
107107
node: ['16.x']
108-
ts: ['4.7', '4.8', '4.9', '5.0']
108+
ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2']
109109
steps:
110110
- name: Checkout repo
111111
uses: actions/checkout@v2
@@ -149,16 +149,7 @@ jobs:
149149
fail-fast: false
150150
matrix:
151151
node: ['16.x']
152-
example:
153-
[
154-
'cra4',
155-
'cra5',
156-
'next',
157-
'vite',
158-
'node-standard',
159-
'node-esm',
160-
'are-the-types-wrong',
161-
]
152+
example: ['cra4', 'cra5', 'next', 'vite', 'node-standard', 'node-esm']
162153
defaults:
163154
run:
164155
working-directory: ./examples/publish-ci/${{ matrix.example }}
@@ -197,9 +188,27 @@ jobs:
197188

198189
- name: Run test step
199190
run: yarn test
200-
if: matrix.example != 'are-the-types-wrong'
201191

202-
- name: Run test step (attw)
203-
# Ignore "FalseCJS" errors in the `attw` job
204-
run: yarn test -n FalseCJS
205-
if: matrix.example == 'are-the-types-wrong'
192+
are-the-types-wrong:
193+
name: Check package config with are-the-types-wrong
194+
195+
needs: [build]
196+
runs-on: ubuntu-latest
197+
strategy:
198+
fail-fast: false
199+
matrix:
200+
node: ['16.x']
201+
steps:
202+
- name: Checkout repo
203+
uses: actions/checkout@v3
204+
205+
- uses: actions/download-artifact@v2
206+
with:
207+
name: package
208+
path: packages/toolkit
209+
210+
- name: show folder
211+
run: ls -l .
212+
213+
- name: Run are-the-types-wrong
214+
run: npx @arethetypeswrong/cli ./package.tgz --format table --ignore-rules false-cjs

docs/api/actionCreatorMiddleware.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ const actionCreatorMiddleware = createActionCreatorInvariantMiddleware({
6363

6464
const store = configureStore({
6565
reducer,
66-
middleware: new Tuple(actionCreatorMiddleware),
66+
middleware: () => new Tuple(actionCreatorMiddleware),
6767
})
6868
```

docs/api/autoBatchEnhancer.mdx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,9 @@ const counterSlice = createSlice({
4848
})
4949
const { incrementBatched, decrementUnbatched } = counterSlice.actions
5050

51+
// includes batch enhancer by default, as of RTK 2.0
5152
const store = configureStore({
5253
reducer: counterSlice.reducer,
53-
// highlight-start
54-
enhancers: (getDefaultEnhancers) => {
55-
// Add the autobatch enhancer to the store setup
56-
return getDefaultEnhancers().concat(autoBatchEnhancer())
57-
},
58-
// highlight-end
5954
})
6055
```
6156

@@ -74,6 +69,25 @@ type AutoBatchOptions =
7469
export type autoBatchEnhancer = (options?: AutoBatchOptions) => StoreEnhancer
7570
```
7671
72+
:::tip
73+
As of RTK 2.0, the `autoBatchEnhancer` is included by default when calling `configureStore`.
74+
75+
This means to configure it, you should instead pass an callback that receives `getDefaultEnhancers` and calls it with your desired settings.
76+
77+
```ts title="Configuring autoBatchEnhancer with getDefaultEnhancers"
78+
import { configureStore } from '@reduxjs/toolkit'
79+
80+
const store = configureStore({
81+
reducer: () => 0,
82+
enhancers: (getDefaultEnhancers) =>
83+
getDefaultEnhancers({
84+
autoBatch: { type: 'tick' },
85+
}),
86+
})
87+
```
88+
89+
:::
90+
7791
Creates a new instance of the autobatch store enhancer.
7892

7993
Any action that is tagged with `action.meta[SHOULD_AUTOBATCH] = true` will be treated as "low-priority", and a notification callback will be queued. The enhancer will delay notifying subscribers until either:
@@ -140,4 +154,4 @@ This allows Redux users to selectively tag certain actions for effective batchin
140154
141155
### RTK Query and Batching
142156
143-
RTK Query already marks several of its key internal action types as batchable. If you add the `autoBatchEnhancer` to the store setup, it will improve the overall UI performance, especially when rendering large lists of components that use the RTKQ query hooks.
157+
RTK Query already marks several of its key internal action types as batchable. By adding the `autoBatchEnhancer` to the store setup, it improves the overall UI performance, especially when rendering large lists of components that use the RTKQ query hooks.

docs/api/codemods.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ hide_title: true
99

1010
# Codemods
1111

12-
Per [the description in `1.9.0-alpha.0`](https://github.com/reduxjs/redux-toolkit/releases/tag/v1.9.0-alpha.0), we plan to remove the "object" argument from `createReducer` and `createSlice.extraReducers` in the future RTK 2.0 major version. In `1.9.0-alpha.0`, we added a one-shot runtime warning to each of those APIs.
12+
Per [the description in `1.9.0`](https://github.com/reduxjs/redux-toolkit/releases/tag/v1.9.0), we have removed the "object" argument from `createReducer` and `createSlice.extraReducers` in the RTK 2.0 major version. We've also added a new optional form of `createSlice.reducers` that uses a callback instead of an object.
1313

1414
To simplify upgrading codebases, we've published a set of codemods that will automatically transform the deprecated "object" syntax into the equivalent "builder" syntax.
1515

16-
The codemods package is available on NPM as [**`@reduxjs/rtk-codemods`**](https://www.npmjs.com/package/@reduxjs/rtk-codemods). It currently contains two codemods: `createReducerBuilder` and `createSliceBuilder`.
16+
The codemods package is available on NPM as [**`@reduxjs/rtk-codemods`**](https://www.npmjs.com/package/@reduxjs/rtk-codemods). It currently contains these codemods:
17+
18+
- `createReducerBuilder`: migrates `createReducer` calls that use the removed object syntax to the builder callback syntax
19+
- `createSliceBuilder`: migrates `createSlice` calls that use the removed object syntax for `extraReducers` to the builder callback syntax
20+
- `createSliceReducerBuilder`: migrates `createSlice` calls that use the still-standard object syntax for `reducers` to the optional new builder callback syntax, including uses of prepared reducers
1721

1822
To run the codemods against your codebase, run `npx @reduxjs/rtk-codemods <TRANSFORM NAME> path/of/files/ or/some**/*glob.js`.
1923

0 commit comments

Comments
 (0)