File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -375,14 +375,14 @@ export default function connectAdvanced(
375
375
376
376
// Now that all that's done, we can finally try to actually render the child component.
377
377
// We memoize the elements for the rendered child component as an optimization.
378
+ const renderedWrappedComponent = useMemo (
379
+ ( ) => < WrappedComponent { ...actualChildProps } ref = { forwardedRef } /> ,
380
+ [ forwardedRef , WrappedComponent , actualChildProps ]
381
+ )
382
+
378
383
// If React sees the exact same element reference as last time, it bails out of re-rendering
379
384
// that child, same as if it was wrapped in React.memo() or returned false from shouldComponentUpdate.
380
385
const renderedChild = useMemo ( ( ) => {
381
- // Render the actual child component
382
- const renderedWrappedComponent = (
383
- < WrappedComponent { ...actualChildProps } ref = { forwardedRef } />
384
- )
385
-
386
386
if ( shouldHandleStateChanges ) {
387
387
// If this component is subscribed to store updates, we need to pass its own
388
388
// subscription instance down to our descendants. That means rendering the same
@@ -395,13 +395,7 @@ export default function connectAdvanced(
395
395
}
396
396
397
397
return renderedWrappedComponent
398
- } , [
399
- ContextToUse ,
400
- WrappedComponent ,
401
- actualChildProps ,
402
- forwardedRef ,
403
- overriddenContextValue
404
- ] )
398
+ } , [ ContextToUse , renderedWrappedComponent , overriddenContextValue ] )
405
399
406
400
return renderedChild
407
401
}
You can’t perform that action at this time.
0 commit comments