Skip to content

Commit cb8d63a

Browse files
authored
Remove unused latestStoreState field
1. This field doesn't actually affect anything: `action.payload` is always a fresh object anyway 2. Having reference to some arbitrary state from the past (namely, the one that triggered the last update for given component) leads to huge memory leaks if the state object is large and there are lots of connected components.
1 parent 388d9e4 commit cb8d63a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/components/connectAdvanced.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export default function connectAdvanced(
244244
// We need to force this wrapper component to re-render whenever a Redux store update
245245
// causes a change to the calculated child component props (or we caught an error in mapState)
246246
const [
247-
[previousStateUpdateResult],
247+
[previousStateUpdateResult, updateCount],
248248
forceComponentUpdateDispatch
249249
] = useReducer(storeStateUpdatesReducer, EMPTY_ARRAY, initStateUpdates)
250250

@@ -350,7 +350,6 @@ export default function connectAdvanced(
350350
forceComponentUpdateDispatch({
351351
type: 'STORE_UPDATED',
352352
payload: {
353-
latestStoreState,
354353
error
355354
}
356355
})

0 commit comments

Comments
 (0)