@@ -253,6 +253,7 @@ export default function connectAdvanced(
253
253
const lastChildProps = useRef ( )
254
254
const lastWrapperProps = useRef ( wrapperProps )
255
255
const childPropsFromStoreUpdate = useRef ( )
256
+ const renderIsScheduled = useRef ( false )
256
257
257
258
const actualChildProps = usePureOnlyMemo ( ( ) => {
258
259
// Tricky logic here:
@@ -282,6 +283,7 @@ export default function connectAdvanced(
282
283
// We want to capture the wrapper props and child props we used for later comparisons
283
284
lastWrapperProps . current = wrapperProps
284
285
lastChildProps . current = actualChildProps
286
+ renderIsScheduled . current = false
285
287
286
288
// If the render was from a store update, clear out that reference and cascade the subscriber update
287
289
if ( childPropsFromStoreUpdate . current ) {
@@ -328,14 +330,17 @@ export default function connectAdvanced(
328
330
329
331
// If the child props haven't changed, nothing to do here - cascade the subscription update
330
332
if ( newChildProps === lastChildProps . current ) {
331
- notifyNestedSubs ( )
333
+ if ( ! renderIsScheduled . current ) {
334
+ notifyNestedSubs ( )
335
+ }
332
336
} else {
333
337
// Save references to the new child props. Note that we track the "child props from store update"
334
338
// as a ref instead of a useState/useReducer because we need a way to determine if that value has
335
339
// been processed. If this went into useState/useReducer, we couldn't clear out the value without
336
340
// forcing another re-render, which we don't want.
337
341
lastChildProps . current = newChildProps
338
342
childPropsFromStoreUpdate . current = newChildProps
343
+ renderIsScheduled . current = true
339
344
340
345
// If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
341
346
forceComponentUpdateDispatch ( {
0 commit comments