From 45e57095016b145abe6dc662f968f4b0a7c0c3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 23 Dec 2021 12:22:47 +0100 Subject: [PATCH] Cleanup more code after `pure` removal --- src/components/connect.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/components/connect.tsx b/src/components/connect.tsx index e9239aa49..eeb3356b4 100644 --- a/src/components/connect.tsx +++ b/src/components/connect.tsx @@ -528,7 +528,6 @@ function connect< const displayName = `Connect(${wrappedComponentName})` const selectorFactoryOptions: SelectorFactoryOptions = { - pure, shouldHandleStateChanges, displayName, wrappedComponentName, @@ -543,11 +542,6 @@ function connect< areMergedPropsEqual, } - // If we aren't running in "pure" mode, we don't want to memoize values. - // To avoid conditionally calling hooks, we fall back to a tiny wrapper - // that just executes the given callback immediately. - const usePureOnlyMemo = pure ? useMemo : (callback: () => any) => callback() - function ConnectFunction( props: InternalConnectProps & TOwnProps ) { @@ -667,7 +661,7 @@ function connect< } }, []) - const actualChildPropsSelector = usePureOnlyMemo(() => { + const actualChildPropsSelector = useMemo(() => { const selector = () => { // Tricky logic here: // - This render may have been triggered by a Redux store update that produced new child props @@ -790,7 +784,6 @@ function connect< return renderedChild } - // If we're in "pure" mode, ensure our wrapper component only re-renders when incoming props have changed. const _Connect = React.memo(ConnectFunction) type ConnectedWrapperComponent = typeof _Connect & {