Skip to content

Commit

Permalink
Use original instead of immer draft for perf
Browse files Browse the repository at this point in the history
  • Loading branch information
Georg Wicke-Arndt committed Mar 15, 2023
1 parent 0734dad commit 711f6fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/toolkit/src/query/core/buildSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
QueryDefinition,
} from '../endpointDefinitions'
import type { Patch } from 'immer'
import { applyPatches } from 'immer'
import { applyPatches, original } from 'immer'
import { onFocus, onFocusLost, onOffline, onOnline } from './setupListeners'
import {
isDocumentVisible,
Expand Down Expand Up @@ -208,7 +208,10 @@ export function buildSlice({
// Assign or safely update the cache data.
substate.data =
definitions[meta.arg.endpointName].structuralSharing ?? true
? copyWithStructuralSharing(substate.data, payload)
? copyWithStructuralSharing(
original(substate.data),
payload
)
: payload
}

Expand Down

0 comments on commit 711f6fe

Please sign in to comment.