Skip to content

Commit 8c53d58

Browse files
committed
Document unexpected Immer behavior with nested produce calls
1 parent c088899 commit 8c53d58

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/entities/entity_state.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ describe('Entity State', () => {
4242
reducers: {
4343
addOne: adapter.addOne,
4444
removeOne(state, action: PayloadAction<string>) {
45-
return adapter.removeOne(state, action)
45+
// TODO The nested `produce` calls don't mutate `state` here as I would have expected.
46+
// TODO (note that `state` here is actually an Immer Draft<S>, from `createReducer`)
47+
// TODO However, this works if we _return_ the new plain result value instead
48+
// TODO See https://github.com/immerjs/immer/issues/533
49+
const result = adapter.removeOne(state, action)
50+
return result
4651
}
4752
},
4853
extraReducers: builder => {

0 commit comments

Comments
 (0)