Skip to content

Commit d0a4fcc

Browse files
committed
call enableES5 from createReducer
1 parent b8f4742 commit d0a4fcc

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/createReducer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Draft } from 'immer'
2-
import createNextState, { isDraft, isDraftable } from 'immer'
2+
import createNextState, { isDraft, isDraftable, enableES5 } from 'immer'
33
import type { AnyAction, Action, Reducer } from 'redux'
44
import type { ActionReducerMapBuilder } from './mapBuilders'
55
import { executeReducerBuilderCallback } from './mapBuilders'
@@ -193,6 +193,12 @@ export function createReducer<S>(
193193
actionMatchers: ActionMatcherDescriptionCollection<S> = [],
194194
defaultCaseReducer?: CaseReducer<S>
195195
): Reducer<S> {
196+
// We deliberately enable Immer's ES5 support, on the grounds that
197+
// we assume RTK will be used with React Native and other Proxy-less
198+
// environments. In addition, that's how Immer 4 behaved, and since
199+
// we want to ship this in an RTK minor, we should keep the same behavior.
200+
enableES5()
201+
196202
let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] =
197203
typeof mapOrBuilderCallback === 'function'
198204
? executeReducerBuilderCallback(mapOrBuilderCallback)

src/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { enableES5 } from 'immer'
21
export * from 'redux'
32
export {
43
default as createNextState,
@@ -18,12 +17,6 @@ export type {
1817
export { createDraftSafeSelector } from './createDraftSafeSelector'
1918
export type { ThunkAction, ThunkDispatch } from 'redux-thunk'
2019

21-
// We deliberately enable Immer's ES5 support, on the grounds that
22-
// we assume RTK will be used with React Native and other Proxy-less
23-
// environments. In addition, that's how Immer 4 behaved, and since
24-
// we want to ship this in an RTK minor, we should keep the same behavior.
25-
enableES5()
26-
2720
export {
2821
// js
2922
configureStore,

0 commit comments

Comments
 (0)