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

Rename internal forwardedRef usage #1553

Merged
merged 2 commits into from Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/components/connectAdvanced.js
Expand Up @@ -272,12 +272,16 @@ export default function connectAdvanced(
const usePureOnlyMemo = pure ? useMemo : callback => callback()

function ConnectFunction(props) {
const [propsContext, forwardedRef, wrapperProps] = useMemo(() => {
const [
propsContext,
reactReduxForwardedRef,
wrapperProps
] = useMemo(() => {
// Distinguish between actual "data" props that were passed to the wrapper component,
// and values needed to control behavior (forwarded refs, alternate context instances).
// To maintain the wrapperProps object reference, memoize this destructuring.
const { forwardedRef, ...wrapperProps } = props
return [props.context, forwardedRef, wrapperProps]
const { reactReduxForwardedRef, ...wrapperProps } = props
return [props.context, reactReduxForwardedRef, wrapperProps]
}, [props])

const ContextToUse = useMemo(() => {
Expand Down Expand Up @@ -437,8 +441,13 @@ export default function connectAdvanced(
// Now that all that's done, we can finally try to actually render the child component.
// We memoize the elements for the rendered child component as an optimization.
const renderedWrappedComponent = useMemo(
() => <WrappedComponent {...actualChildProps} ref={forwardedRef} />,
[forwardedRef, WrappedComponent, actualChildProps]
() => (
<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 Expand Up @@ -472,7 +481,7 @@ export default function connectAdvanced(
props,
ref
) {
return <Connect {...props} forwardedRef={ref} />
return <Connect {...props} reactReduxForwardedRef={ref} />
})

forwarded.displayName = displayName
Expand Down