From ab027bc422aa95cd79b621ee34cc54db2a839675 Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Mon, 29 Apr 2024 22:35:48 -0500 Subject: [PATCH 1/2] Fix `useRef` usages to be called with an explicit `undefined` argument. - This change was made by running `npx types-react-codemod useRef-required-initial .` in preparation for React 19. --- src/components/connect.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/connect.tsx b/src/components/connect.tsx index bdad73719..4137a6d7b 100644 --- a/src/components/connect.tsx +++ b/src/components/connect.tsx @@ -641,13 +641,13 @@ function connect< }, [didStoreComeFromProps, contextValue, subscription]) // Set up refs to coordinate values between the subscription effect and the render logic - const lastChildProps = React.useRef() + const lastChildProps = React.useRef(undefined) const lastWrapperProps = React.useRef(wrapperProps) - const childPropsFromStoreUpdate = React.useRef() + const childPropsFromStoreUpdate = React.useRef(undefined) const renderIsScheduled = React.useRef(false) const isMounted = React.useRef(false) - const latestSubscriptionCallbackError = React.useRef() + const latestSubscriptionCallbackError = React.useRef(undefined) useIsomorphicLayoutEffect(() => { isMounted.current = true @@ -752,11 +752,11 @@ function connect< const renderedWrappedComponent = React.useMemo(() => { return ( // @ts-ignore - - ) + />) + ); }, [reactReduxForwardedRef, WrappedComponent, actualChildProps]) // If React sees the exact same element reference as last time, it bails out of re-rendering From 1916b0d558fe541455b2690b5ce9ccf8dc2afa1e Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Mon, 29 Apr 2024 22:59:22 -0500 Subject: [PATCH 2/2] Fix type issue related to `latestSubscriptionCallbackError` --- src/components/connect.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/connect.tsx b/src/components/connect.tsx index 4137a6d7b..23d4c1828 100644 --- a/src/components/connect.tsx +++ b/src/components/connect.tsx @@ -647,7 +647,11 @@ function connect< const renderIsScheduled = React.useRef(false) const isMounted = React.useRef(false) - const latestSubscriptionCallbackError = React.useRef(undefined) + // TODO: Change this to `React.useRef(undefined)` after upgrading to React 19. + /** + * @todo Change this to `React.useRef(undefined)` after upgrading to React 19. + */ + const latestSubscriptionCallbackError = React.useRef(undefined) useIsomorphicLayoutEffect(() => { isMounted.current = true