This release fixes a couple edge cases with Immer usage and reducers, and exposes the
typePrefix field from thunks generated by
Immer Reducer Fixes
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.
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.
- 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)