yarn @reduxjs/toolkit 1.3.6
v1.3.6

This release fixes a couple edge cases with Immer usage and reducers, and exposes the typePrefix field from thunks generated by createAsyncThunk.

Changes

Immer Reducer Fixes

The createEntityAdapter CRUD methods can be used as either standalone reducers (in which case they call createNextState() internally) or "mutating" helper functions if given an existing Immer Draft value. However, createReducer always assumed you were using the reducer standalone.

If you were trying to wrap createReducer and pass in a Draft value, changes inside wouldn't be reflected in the external Draft. We've updated createReducer to check if the incoming state value is actually a `Draft.

Also, the removeAll CRUD method from createEntityAdapter wasn't working correctly when used as a mutating helper, for similar reasons. We've tweaked the logic there to work right.

Thunk Type Prefix

createAsyncThunk accepts a typePrefix string as its first argument, and uses that to generate the pending/fulfilled/rejected action types it dispatches. We had some requests to expose that type string for later usage, so the thunk function now has a thunk.typePrefix field containing that string.

Changelog

  • expose createAsyncThunk typePrefix parameter on the actionCreator (@phryneas - #546)
  • Allow nested Immer produce statements with createReducer (@AndrewCraswell - #509)
  • fix #541: invoke removeAll mutably within produce (@phryneas - #544)

https://github.com/reduxjs/redux-toolkit/compare/v1.3.5...v1.3.6

latest releases: 1.5.0, 1.4.0
6 months ago