The ConnectOptions section specifies that if the "withRef" option is set to true, the wrapped component's ref will be available through the getWrappedInstance() function on the connected component.
However, the getWrappedInstance() function is not defined in the react-redux typings so it is unavailable for use.
@types/react-redux v6.0.2 package and had problems.Definitions by: in index.d.ts) so they can respond.Same issue here
Any movement here?
Until typings are provided use cast to any type. Like:
ref = { comp => this.myCompRef = (comp as any).getWrappedInstance() }
export type Instance<T> = T extends { new (...args: any[]): infer U } ? U : never;
export type GetProps<T> = T extends React.ComponentType<infer P> ? P : never;
export type GetWrappedComponent<T> = T extends { WrappedComponent: infer C } ? C : never;
export type ConnectWithRef<T> = {
new (props: GetProps<T>): Instance<T> & {
getWrappedInstance?: () => Instance<GetWrappedComponent<T>>,
},
};
...
const ConnectedComponent = connect(mapStateToProps, null, null, { withRef: true })(DumbComponent);
export default ConnectedComponent as ConnectWithRef<typeof ConnectedComponent>;