Skip to content

Commit 72b2214

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit into migrate-to-react-19
2 parents 5e99764 + 4578c74 commit 72b2214

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

docs/tutorials/quick-start.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ npm install @reduxjs/toolkit react-redux
4949

5050
Create a file named `src/app/store.js`. Import the `configureStore` API from Redux Toolkit. We'll start by creating an empty Redux store, and exporting it:
5151

52-
```ts title="app/store.js"
52+
```ts title="app/store.ts"
5353
import { configureStore } from '@reduxjs/toolkit'
5454

5555
export const store = configureStore({
@@ -321,4 +321,4 @@ Here's the complete counter application as a running CodeSandbox:
321321

322322
## What's Next?
323323

324-
We recommend going through [**the "Redux Essentials" and "Redux Fundamentals" tutorials in the Redux core docs**](https://redux.js.org/tutorials/index), which will give you a complete understanding of how Redux works, what Redux Toolkit does, and how to use it correctly.
324+
We recommend going through [**the "Redux Essentials" and "Redux Fundamentals" tutorials in the Redux core docs**](https://redux.js.org/tutorials/index), which will give you a complete understanding of how Redux works, what Redux Toolkit does, and how to use it correctly.

packages/toolkit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reduxjs/toolkit",
3-
"version": "2.2.4",
3+
"version": "2.2.5",
44
"description": "The official, opinionated, batteries-included toolset for efficient Redux development",
55
"author": "Mark Erikson <[email protected]>",
66
"license": "MIT",
@@ -106,7 +106,7 @@
106106
"format": "prettier --write \"(src|examples)/**/*.{ts,tsx}\" \"**/*.md\"",
107107
"format:check": "prettier --list-different \"(src|examples)/**/*.{ts,tsx}\" \"docs/*/**.md\"",
108108
"lint": "eslint src examples",
109-
"test": "vitest --run --typecheck",
109+
"test": "vitest --typecheck --run ",
110110
"test:watch": "vitest --watch",
111111
"type-tests": "yarn tsc -p tsconfig.test.json --noEmit",
112112
"prepack": "yarn build",

packages/toolkit/src/entities/tests/sorted_state_adapter.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
createSlice,
66
configureStore,
77
nanoid,
8+
PayloadAction,
89
} from '@reduxjs/toolkit'
910
import type { BookModel } from './fixtures/book'
1011
import {
@@ -783,6 +784,30 @@ describe('Sorted State Adapter', () => {
783784
//expect(numSorts).toBeLessThan(25_000)
784785
})
785786

787+
it('should not throw an Immer `current` error when `state.ids` is a plain array', () => {
788+
const book1: BookModel = { id: 'a', title: 'First' }
789+
const initialState = adapter.getInitialState()
790+
const withItems = adapter.addMany(initialState, [book1])
791+
const booksSlice = createSlice({
792+
name: 'books',
793+
initialState,
794+
reducers: {
795+
testCurrentBehavior(state, action: PayloadAction<BookModel>) {
796+
// Will overwrite `state.ids` with a plain array
797+
adapter.removeAll(state)
798+
799+
// will call `splitAddedUpdatedEntities` and call `current(state.ids)`
800+
adapter.upsertMany(state, [book1])
801+
},
802+
},
803+
})
804+
805+
booksSlice.reducer(
806+
initialState,
807+
booksSlice.actions.testCurrentBehavior(book1),
808+
)
809+
})
810+
786811
describe('can be used mutably when wrapped in createNextState', () => {
787812
test('removeAll', () => {
788813
const withTwo = adapter.addMany(state, [TheGreatGatsby, AnimalFarm])

packages/toolkit/src/entities/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function splitAddedUpdatedEntities<T, Id extends EntityId>(
4747
): [T[], Update<T, Id>[], Id[]] {
4848
newEntities = ensureEntitiesArray(newEntities)
4949

50-
const existingIdsArray = current(state.ids) as Id[]
50+
const existingIdsArray = getCurrent(state.ids) as Id[]
5151
const existingIds = new Set<Id>(existingIdsArray)
5252

5353
const added: T[] = []

0 commit comments

Comments
 (0)