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(
375375
376376 // Now that all that's done, we can finally try to actually render the child component.
377377 // 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+
378383 // If React sees the exact same element reference as last time, it bails out of re-rendering
379384 // that child, same as if it was wrapped in React.memo() or returned false from shouldComponentUpdate.
380385 const renderedChild = useMemo ( ( ) => {
381- // Render the actual child component
382- const renderedWrappedComponent = (
383- < WrappedComponent { ...actualChildProps } ref = { forwardedRef } />
384- )
385-
386386 if ( shouldHandleStateChanges ) {
387387 // If this component is subscribed to store updates, we need to pass its own
388388 // subscription instance down to our descendants. That means rendering the same
@@ -395,13 +395,7 @@ export default function connectAdvanced(
395395 }
396396
397397 return renderedWrappedComponent
398- } , [
399- ContextToUse ,
400- WrappedComponent ,
401- actualChildProps ,
402- forwardedRef ,
403- overriddenContextValue
404- ] )
398+ } , [ ContextToUse , renderedWrappedComponent , overriddenContextValue ] )
405399
406400 return renderedChild
407401 }
You can’t perform that action at this time.
0 commit comments