Skip to content

Commit 17451c1

Browse files
josepotmarkerikson
authored andcommitted
[FIX]: #1219 Save references before update (#1220)
1 parent 73c0fbd commit 17451c1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/components/connectAdvanced.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ export default function connectAdvanced(
330330
if (newChildProps === lastChildProps.current) {
331331
notifyNestedSubs()
332332
} else {
333+
// Save references to the new child props. Note that we track the "child props from store update"
334+
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
335+
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
336+
// forcing another re-render, which we don't want.
337+
lastChildProps.current = newChildProps
338+
childPropsFromStoreUpdate.current = newChildProps
339+
333340
// If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
334341
forceComponentUpdateDispatch({
335342
type: 'STORE_UPDATED',
@@ -338,13 +345,6 @@ export default function connectAdvanced(
338345
error
339346
}
340347
})
341-
342-
// Save references to the new child props. Note that we track the "child props from store update"
343-
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
344-
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
345-
// forcing another re-render, which we don't want.
346-
lastChildProps.current = newChildProps
347-
childPropsFromStoreUpdate.current = newChildProps
348348
}
349349
}
350350

0 commit comments

Comments
 (0)