"getWrappedInstance is not a function"
See original GitHub issueGreetings,
I want to use Ref on my connect components. A search through google finds everyone suggesting to pass {withRef: true} as the 4th argument to connect() and then use ref. getWrappedInstance() to access the wrapped instance of the component.
However, when I try it I’m getting “getWrappedInstance is not a function”. I read through the docs, is getRef only available in advancedConnect() now?
I attempted to use advancedConnect but the documentation for selectorFactory is difficult to understand and I couldn’t make the change from connect to advancedConnect.
Here is my code snippet:
export default connect(mapStateToProps, mapDispatchToProps, null, { withRef: true })(Element);
and ref.getWrappedInstance() simple gives me “getWrappedInstance is not a function”.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top GitHub Comments
Nevermind, I don’t know how I missed it, but it’s just been replaced by the
forwardRef
option seen here (which removes the need forgetWrappedInstance
): https://react-redux.js.org/api/connect#forwardref-booleangetWrappedInstance
is a function on the element itself. You can use it like our tests do.