Skip to content

Commit a28484f

Browse files
author
Georg Wicke-Arndt
committed
Use original instead of immer draft for perf
1 parent 0734dad commit a28484f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/toolkit/src/query/core/buildSlice.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import type {
3131
EndpointDefinitions,
3232
QueryDefinition,
3333
} from '../endpointDefinitions'
34-
import type { Patch } from 'immer'
34+
import { original, Patch } from 'immer'
3535
import { applyPatches } from 'immer'
3636
import { onFocus, onFocusLost, onOffline, onOnline } from './setupListeners'
3737
import {
@@ -208,7 +208,10 @@ export function buildSlice({
208208
// Assign or safely update the cache data.
209209
substate.data =
210210
definitions[meta.arg.endpointName].structuralSharing ?? true
211-
? copyWithStructuralSharing(substate.data, payload)
211+
? copyWithStructuralSharing(
212+
original(substate.data),
213+
payload
214+
)
212215
: payload
213216
}
214217

0 commit comments

Comments
 (0)