Skip to content

External property ref is always overridden with value undefined #2251

@PSpSynedra

Description

@PSpSynedra

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React: 19.1.1
  • Redux: 5.0.1
  • React Redux: 9.2.0

What is the current behavior?

Whe wrapping a component with connect without passing the option forwardRef set to true, the wrapped component always receives a prop ref with value undefined overriding any other prop named ref:

function WrappedComponent(props) {
   const {ref} = props
   // ref will always be undefined  when wrapped within connect like below.
   return <pan ref={ref} />
}

function HocComponent(props) {
   const [wrapperRef, setRef] = useState(null)
   // The current behavior of connect would override the ref!
   return <WrappedComponent ref={setRef} {...props} />
}
export default connect(...)(HocComponent)

What is the expected behavior?

A passed property ref is passed to the wrapped component, when the option fowardRef is not present or falsy.

Which browser and OS are affected by this issue?

No response

Did this work in previous versions of React Redux?

  • Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions