Skip to content

Commit 921b440

Browse files
authored
Merge pull request #1859 from Andarist/cleanup-pure
2 parents a30e8b4 + 45e5709 commit 921b440

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/components/connect.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ function connect<
528528
const displayName = `Connect(${wrappedComponentName})`
529529

530530
const selectorFactoryOptions: SelectorFactoryOptions<any, any, any, any> = {
531-
pure,
532531
shouldHandleStateChanges,
533532
displayName,
534533
wrappedComponentName,
@@ -543,11 +542,6 @@ function connect<
543542
areMergedPropsEqual,
544543
}
545544

546-
// If we aren't running in "pure" mode, we don't want to memoize values.
547-
// To avoid conditionally calling hooks, we fall back to a tiny wrapper
548-
// that just executes the given callback immediately.
549-
const usePureOnlyMemo = pure ? useMemo : (callback: () => any) => callback()
550-
551545
function ConnectFunction<TOwnProps>(
552546
props: InternalConnectProps & TOwnProps
553547
) {
@@ -667,7 +661,7 @@ function connect<
667661
}
668662
}, [])
669663

670-
const actualChildPropsSelector = usePureOnlyMemo(() => {
664+
const actualChildPropsSelector = useMemo(() => {
671665
const selector = () => {
672666
// Tricky logic here:
673667
// - This render may have been triggered by a Redux store update that produced new child props
@@ -790,7 +784,6 @@ function connect<
790784
return renderedChild
791785
}
792786

793-
// If we're in "pure" mode, ensure our wrapper component only re-renders when incoming props have changed.
794787
const _Connect = React.memo(ConnectFunction)
795788

796789
type ConnectedWrapperComponent = typeof _Connect & {

0 commit comments

Comments
 (0)