This bugfix release fixes a few minor issues and bits of behavior, including stable sorting in
createEntityAdapter.updateMany
and some initial state handling in createSlice
.
Changelog
Entity Adapter Updates
Previously, applying updates via createEntityAdapter.updateMany
caused sorting order to change. Entities that had the same sorting result should have stayed in the same order relative to each other, but if one of those items had any updates, it would sort to the back of that group. This was due to items being removed from the lookup table and re-added, and since JS engines iterate keys in insertion order, the updated item would now end up compared later than before.
We've reworked the implementation of updateMany
to avoid that. This also ended up fixing another issue where multiple update entries targeting the same item ID would only have the first applied.
createSlice
Initial State
createSlice
now logs an error if initialState
is undefined
. This is most commonly seen when users misspell initialState
. It also has better handling for values that can't be frozen by Immer such as primitives.
RTK Query
Several assorted improvements, including TS types for BaseQuery
and checking if the body can actually be safely stringified.
What's Changed
- Add Missing Else to enhanceEndpoints Function by @kinson in https://github.com/reduxjs/redux-toolkit/pull/2386
- Check initial state is draftable before using immer to freeze it. by @EskiMojo14 in https://github.com/reduxjs/redux-toolkit/pull/2378
- Check that body isJsonifiable before stringify by @ShaunDychko in https://github.com/reduxjs/redux-toolkit/pull/2330
- Respect BaseQuery meta types when enhancing by @TamasSzigeti in https://github.com/reduxjs/redux-toolkit/pull/2225
- Throw new error when initial state is undefined by @dannielss in https://github.com/reduxjs/redux-toolkit/pull/2461
- Rewrite
updateMany
to ensure stable sorting order by @markerikson in https://github.com/reduxjs/redux-toolkit/pull/2464
New Contributors
Full Changelog: https://github.com/reduxjs/redux-toolkit/compare/v1.8.2...1.8.3