Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix useRef usages to be called with an explicit argument of undefined. #2164

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/components/connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,13 +641,17 @@ function connect<
}, [didStoreComeFromProps, contextValue, subscription])

// Set up refs to coordinate values between the subscription effect and the render logic
const lastChildProps = React.useRef<unknown>()
const lastChildProps = React.useRef<unknown>(undefined)
const lastWrapperProps = React.useRef(wrapperProps)
const childPropsFromStoreUpdate = React.useRef<unknown>()
const childPropsFromStoreUpdate = React.useRef<unknown>(undefined)
const renderIsScheduled = React.useRef(false)
const isMounted = React.useRef(false)

const latestSubscriptionCallbackError = React.useRef<Error>()
// TODO: Change this to `React.useRef<Error>(undefined)` after upgrading to React 19.
/**
* @todo Change this to `React.useRef<Error>(undefined)` after upgrading to React 19.
*/
const latestSubscriptionCallbackError = React.useRef<Error | undefined>(undefined)

useIsomorphicLayoutEffect(() => {
isMounted.current = true
Expand Down Expand Up @@ -752,11 +756,11 @@ function connect<
const renderedWrappedComponent = React.useMemo(() => {
return (
// @ts-ignore
<WrappedComponent
(<WrappedComponent
{...actualChildProps}
ref={reactReduxForwardedRef}
/>
)
/>)
);
}, [reactReduxForwardedRef, WrappedComponent, actualChildProps])

// If React sees the exact same element reference as last time, it bails out of re-rendering
Expand Down
Loading