Skip to content

Commit 0532803

Browse files
committed
Specifically disable Immer strict iteration for perf
1 parent 98de804 commit 0532803

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/toolkit/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {
1111
isDraft,
1212
} from 'immer'
1313
export type { Draft, WritableDraft } from 'immer'
14+
import { setUseStrictIteration } from 'immer'
1415
export {
1516
createSelector,
1617
createSelectorCreator,
@@ -216,3 +217,10 @@ export type {
216217
} from './tsHelpers'
217218

218219
export { formatProdErrorMessage } from './formatProdErrorMessage'
220+
221+
// Immer 10.2 defaults to still using strict iteration (specifically
222+
// `Reflect.ownKeys()` for symbols support). However, we assume that
223+
// Redux users are not using symbols as state keys, so we'll override
224+
// this to prefer `Object.keys()` instead, as it provides a ~10% speedup.
225+
// If users do need symbol support, they can call `setUseStrictIteration(true)` themselves.
226+
setUseStrictIteration(false)

0 commit comments

Comments
 (0)